Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

URI encoding breaks linking to text fragments #793

Open
dchacke opened this issue Oct 26, 2024 · 0 comments
Open

URI encoding breaks linking to text fragments #793

dchacke opened this issue Oct 26, 2024 · 0 comments

Comments

@dchacke
Copy link
Contributor

dchacke commented Oct 26, 2024

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
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant