10

When supplying a link that highlights the text on a web page (in Chrome, see note below), a tilde character ~ is used as part of the URL to identify text to highlight:

https://meta.stackexchange.com/q/370143/#:~:text=highlights%20the%20text%20on%20a%20web%20page

When using a link like this with Markdown, the tilde is escaped to %7E. (In particular, this caused text highlighting to fail on three .gov and one .org site that I encountered over a four day period.) Today, I tested meta.stackexchange.com and had the same problem.

On Stack Exchange, text highlighting only works when the link is created as HTML anchor tags (<a>), with the link specified as the href attribute.

For example:

  • HTML link: How do I search tags?

    • https://meta.stackexchange.com/help/interesting-topics#:~:text=Search%20tags,on%20%22advanced%20tips%22.
  • Markdown link ([text][1]), How do I search tags?

    • https://meta.stackexchange.com/help/interesting-topics#:%7E:text=Search%20tags,on%20%22advanced%20tips%22.

Markdown links are much easier to interpret when composing a post, but tildes are escaped when using them, which makes the highlight feature fail.

In a previous question, Link with underscore does not work, a problem with underscores (_) being changed to %5F was noted and has since been resolved.

Could a change be made to prevent escaping the tilde character (~) in Markdown links?


* - "Link to highlight" is a standard feature in Google Chrome, and is available as an addon for other browsers.

5
  • So, to clarify, links composed as HTML anchor elements (<a>) keep the ~ character unescaped, but Markdown footnote links do not. Does this happen with Markdown inline links ([link text](url)) as well?
    – zcoop98
    Sep 22 at 19:04
  • @zcoop98 - Didn't try it. I don't normally use that form.
    – Rick Smith
    Sep 22 at 19:07
  • 3
    It appears it's the same, inline links also escape the ~, breaking highlighting.
    – zcoop98
    Sep 22 at 19:14
  • See also: stackoverflow.com/a/62162093
    – Rob
    Sep 22 at 19:25
  • 1
    @Rick Just made a pretty substantial edit to try and improve the overall clarity of what's going on, and highlight specifically why the link isn't working. If you feel its too drastic, or strayed too far, please feel free to rollback or edit it to your linking.
    – zcoop98
    Sep 22 at 19:51

You must log in to answer this question.

Browse other questions tagged .