In this answer, I attempt to add a link with a "scroll-to-text" anchor


edit history of dba.se q 275435 rev 2 side-by-side markdown

Pasting that exact text into the URL bar of a new tab on Chrome should take you about halfway down the page and display the following on page load.

postgresql 13 release notes section E.1.3.4.

At present the link I give in markdown is highjacked such that the html#:~:text= element becomes URL-safe html#:%7E:text= (right-click > copy link to see the behaviour). Therefore the auto-scroll and highlight do not occur.

Note that testing the link from the edit->preview pane seems to indicate that the link is well-formed (as seen here); while opening the link from the final rendered page appears malformed (as seen here).


Note that a reasonably trivial workaround exists (in chrome) whereby you can make trivial edit in the URL bar and reload the page to force auto-scroll to the anchor; as shown on imgur or in the gif below.

delete one character then press enter to force re-load with deep link


1 Answer 1


I ran your post through MarkdownSharp and the tilde was not encoded during the rendering from markdown to HTML. So the problem is likely elsewhere on the server side. Hopefully an SO dev will come along and check on this. The tilde doesn't need to be encoded in a URI, since it's an unreserved character.

The live preview (when editing) is not affected by the encoding problem because that is done client side (using pagedown).

As a side note, the ScrollToTextFragment feature requires "noopener" semantics to protect against potential security issues:

Additionally, the fragment will activate only if the document is sufficiently isolated from other pages (is the only one in its browsing context group, e.g. no window.opener or iframes).

source: Text Fragments

Your link already has "noreferrer" set (standard in posts, I think) which provides the same protection in this case (it also doesn't have a "target" attribute so the opener wouldn't be set anyway), so the autoscroll and highlight feature should work once the tilde is not encoded.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .