redcarpet
redcarpet copied to clipboard
URI encoding breaks linking to text fragments
Redcarpet seems to automatically URI encode the href for links. That’s fine in most cases except when linking to text fragments, where the tilde must not be encoded.
Current behavior:
'[foo](https://example.com#:~:text=bar)'
# => href: 'https://example.com#:%7E:text=bar'
# ^
Expected behavior:
'[foo](https://example.com#:~:text=bar)'
# => href: 'https://example.com#:~:text=bar'
# ^
As a workaround, I use a heuristic for post processing:
def postprocess text
text.gsub('#:%7E:text=', '#:~:text=')
end