2

Text location hashes are useful when pasting a URL to a page without anchors.

Here are some live examples:

These are escaped by Stack Overflow. When you directly click the link, the highlight doesn't work. A user has to copy the URL and paste to a browser location bar manually. In the edit preview it is fine, but in normal view mode, it is escaped: :~:text become :%7E:text, and the anchors ineffective.

6
  • I know this has been discussed previously, but I don't recall if there's a duplicate question. Prior experimentation indicated that such URLs do work in comments, but not posts.
    – Makyen
    Dec 27, 2022 at 17:27
  • 5
    Such URLs are non-standard. In fact, they specifically use reserved characters to have the additional :~:text delimiter. Such URLs are, currently, only supported in Chromium. I don't know if other browsers are moving to support them. That such URLs are not currently functional in posts is a bug/FR in Chromium, not Stack Exchange, IMO. What's preventing the URLs from being functional is that SE's backend percent encodes the ~ to %7E. That's perfectly valid and common. If Chromium wants to use :~:text, then Chromium should decode the %7E, which is explicitly permitted.
    – Makyen
    Dec 27, 2022 at 17:50
  • 1
    There is a comment in the linked suggested duplicate that says if you use an anchor tag instead of markdown, so <a href="foo.com:~:text">foo</a> instead of [foo](foo.com:~:text), the tilde symbol is preserved and scroll to text fragments will work. Just tried it myself and it indeed works with anchor tags. See my test answer here: meta.stackexchange.com/a/357228/299995 Dec 27, 2022 at 18:09
  • 1
    @Makyen but on stackoverflow, edit preview, normal view, comment view they don't have same behavior
    – yurenchen
    Dec 28, 2022 at 0:21
  • 1
    @CaveJohnson that's good workaround, thanks
    – yurenchen
    Dec 28, 2022 at 0:21
  • @yurenchen The edit preview, backend conversion for posts, backend conversion for comments, chat pre-conversion, and chat backend conversion all use different code and/or settings for Markdown -> HTML conversion. There's quite a number of discrepancies between how the all of them operate. While I agree that all of them should be nearly identical, they aren't. This is just yet one more way in which they aren't the same.
    – Makyen
    Dec 28, 2022 at 1:54

0

Browse other questions tagged .