Skip to content

URI encoding breaks linking to text fragments #793

@dchacke

Description

@dchacke

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions