mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-29 19:05:59 +00:00
The generated table of contents usually has IDs for each TOC link, allowing to link back to specific parts of the TOC. However, this leads to unidiomatic markup in formats like gfm, which do not support attributes on links and hence fall back to HTML. The IDs on TOC items are now removed in that case, leading to more aesthetic TOCs. Closes: #8131
42 lines
663 B
Markdown
42 lines
663 B
Markdown
# TOC in gfm contains no HTML by default
|
|
```
|
|
% pandoc --to=gfm --toc --standalone
|
|
# Head
|
|
|
|
Content
|
|
^D
|
|
- [Head](#head)
|
|
|
|
# Head
|
|
|
|
Content
|
|
```
|
|
|
|
# Same in Markdown if link_attributes extension is disabled
|
|
```
|
|
% pandoc --to=markdown-link_attributes --toc --standalone
|
|
# Head
|
|
|
|
Content
|
|
^D
|
|
- [Head](#head)
|
|
|
|
# Head
|
|
|
|
Content
|
|
```
|
|
|
|
# IDs are added to TOC with the "attributes" CommonMark extension
|
|
```
|
|
% pandoc --to=commonmark+gfm_auto_identifiers+attributes --toc -s
|
|
# Nam a sapien
|
|
|
|
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
|
|
^D
|
|
- [Nam a sapien](#nam-a-sapien){#toc-nam-a-sapien}
|
|
|
|
# Nam a sapien
|
|
|
|
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
|
|
```
|