Add Anchor ID to Text

AI-generated summary

The topic Add Anchor ID to Text discusses automatically adding anchor link IDs to markdown headers. fyodorovich inquired if this feature is available, as they can see it working in their TOS, but not when trying to create deep links to inline elements.

JammyDodger confirmed that it works and provided an example using <a name="anchor"></a>. They also explained that headers are automatically assigned an anchor ID when using the ### markdown code.

JammyDodger shared their method for generating links and anchors, which involves using the ### markdown code for headers and grabbing the link from the icon that appears. fyodorovich was able to reproduce this method and confirmed it’s working for them.

Did this ever become a reality?

I can see deep links to Headings working in my TOS. However, when I try to create deep link to inline elements, such as span or anchors, the ID is stripped from the tag, making the link useless.

Is it only possible to link to header elements?

I’m pretty sure it works?

If you tap on the header above a link icon should appear on the left.

I also use eg. <a name="anchor"></a>, and they work too.

Add Anchor ID to Text - #2 by JammyDodger



    :backhand_index_pointing_left: hidden anchor

(anchor zips to here ish)

how are you generating the link and the anchor. I’m trying to follow the usage in the terms of service table of contents. When I save the post and use the dev inspector to look at the code I can see that the tag has persisted but the attributes have been removed.

For the headers I just use the # markdown code for header, and the forum does the rest.

### Anchor Header

Anchor Header

And then when I grab the link from then icon I get

https://meta.discourse.org/t/add-anchor-id-to-text/201393/4#anchor-header-1

I’m afraid I don’t use them in tocs (though I thought the TOC also did them automatically for you based on the same principle?)

OK. thanks for the explanation. I’ve been able to reproduce that and it’s working.