xijo / reverse_markdown

Ruby gem to convert html into markdown
Do What The F*ck You Want To Public License
628 stars 118 forks source link

Links to ids don't produce Markdown links #82

Closed movermeyer closed 4 years ago

movermeyer commented 4 years ago

When thehref is to an HTML id, no link is generated

link_to_external_site = '<a href="https://example.com#hallo">Hallo!</a>'
link_to_id = '<a href="#hallo">Hallo!</a>'

ReverseMarkdown.convert(link_to_external_site, github_flavored: true, tag_border: '')
=> "[Hallo!](https://example.com#hallo)"

ReverseMarkdown.convert(link_to_id, github_flavored: true, tag_border: '')
=> "Hallo!"

In the second case, I expected [Hallo!](#hallo), not Hallo!.

movermeyer commented 4 years ago

Looking into this further, it seems that this was intended behaviour at one point:

I'd like to argue that this is the wrong behaviour. Markdown/CommonMark supports jump links (see this file's table of contents for example) and the CommonMark spec allows for any characters in the link destination, including fragments

xijo commented 4 years ago

Hi,

Thanks for reporting. Sounds right: jump marks should work as you'd expect them to. I'll have a look and get back to you alright?

Cheers, Jo

xijo commented 4 years ago

Released as 1.4.0. Thanks again!