Android-FileBrowser-FilePicker icon indicating copy to clipboard operation
Android-FileBrowser-FilePicker copied to clipboard

Heading subscripts are stripped out in TOC extension

Open cjbraun opened this issue 5 years ago • 2 comments

A heading with a subscript, i.e. ### CO<sub>2</sub> Emissions now gets the <sub> tag stripped out in the table of contents as of the 3.2 release (issue #899).

I understand that arbitrary HTML in the headings is undesirable, but for some formatting tags it seems like the most straightforward approach.

Until there is a different way to format TOC entries, is there a workaround for this, or do I just need to keep using an older release?

cjbraun avatar Apr 07 '20 21:04 cjbraun

I understand that arbitrary HTML in the headings is undesirable, but for some formatting tags it seems like the most straightforward approach.

The problem is that we would need to parse the raw HTML and check the tag against a whitelist to do that. We don't actually parse raw HTML (we just remove anything between < and >. I'm not sure if we want to get any more sophisticated than that.

is there a workaround for this

You can define a custom label if you are also using the attr_list extension via the data-toc-label attribute. However, that also strips out raw HTML tags.

waylan avatar Jun 30 '20 19:06 waylan

Have you considered to return the raw Markdown or HTML in raw_md or raw_html keys of toc_tokens output of toc extension @waylan? This would allow to Mkdocs to format the table of contents properly.

mondeja avatar Dec 18 '21 12:12 mondeja

This is a duplicate of #660. Not sure how I missed that before.

waylan avatar Apr 18 '23 15:04 waylan