Repository navigation
Table of contents generation from HTML #40
Replies: 1 comment 2 replies
|
This is the current behaviour, and it follows directly from how the renderer is built. TOC entries are created in exactly one place: HTMLRenderer.visitHeading, which appends a TOCEntry every time the markdown AST hands it a Heading node. Headings written as raw HTML inside a block are emitted by a different code path - visitHTMLBlock, which simply appends the raw HTML to the output and never parses it. IMHO, the restriction is structural rather than a deliberate filtering rule, because swift-markdown treats an HTML block as an opaque node rather than re-parsing its contents as markdown. If you want a heading to appear in the TOC it has to be written in markdown syntax, so the practical approach is: use a markdown heading for anything that should be navigable, and attach styling by targeting the generated anchor id, which is derived from the heading text by the slugger and emitted as the heading's id attribute. Good luck! |
Uh oh!
There was an error while loading. Please reload this page.
The table of contents is generated using the markdown syntax.
When using HTML in markdown to define h1-6 titles, those are ignored.
Is this an intended behavior ?
How should I do if I want to add an h title inside an HTML block with classes for styling ?
Given the right direction I may open a pull request.
All reactions