Clean segments

PR for #450

I hope it doesn't seem overkilling, I kept it as small as possible.
Comments are welcome. I'll be posting some test units, if I can manage to make them work.

Meanwhile I tested it with
```markdown
### Heading with a [link](http://github.com/)

### Heading with some _italic text_

### Or some **strong**
(which doesn't really make any difference, here)

### Or even `code`

### What about ~~strikethrough~~
```

and I got

```html
<h3 id="heading-with-a-link">Heading with a <a href="http://github.com/">link</a></h3>
<h3 id="heading-with-some-italic-text">Heading with some <em>italic text</em></h3>
<h3 id="or-some-strong">Or some <strong>strong</strong></h3>
<p>(which doesn&#39;t really make any difference, here)</p>
<h3 id="or-even-code">Or even <code>code</code></h3>
<h3 id="what-about-strikethrough">What about <del>strikethrough</del></h3>
```

which looks good to me.