mkdocs-exporter
mkdocs-exporter copied to clipboard
Automatically create a table of contents from headers in generated PDF
Hello
I am wondering if it is possible to automatically generate a table of contents (TOC) when a PDF is created based off of the headers in the markdown file that is being converted to PDF?
If not, would this be something considered as an enhancement to the plugin?
Thank you!
Hello @SteveBehm,
Currently, this feature is not implemented but could definitely be an enhancement to the plugin.
We'd very much appreciate a table of contents as well, especially for PDF's containing many (hundreds of) pages.
As a side note: This implementation of a PDF expert is creative and significantly better than all previously implementations I've seen, great work!
Hi,
Using these, the table of contents can be generated by the existing Markdown extensions.
pagename.md:
---
[TOC]
<span class="page-break"></span>
mkdocs.yml, using thetocextension:
# Pages extensions
markdown_extensions:
- toc:
permalink: true
title: Table of contents
title_class: toc-title
toc_depth: 2-3
custom.css, hiding the TOC on my web generation (but that's my use case):
.toc {
display: none;
}
.toc-title {
font-size: 1.5625em;
font-weight: 300;
}
pdf.scss, showing the configured TOC in PDF generated documentation:
.page-break {
display: none;
page-break-after: always;
}
.toc {
display: initial;
}
- Example: https://radiandevcore.gitlab.io/tools/pre-commit-crocodile/index.pdf