Skip to content

feat(pdf): Add pdfTocSource option to generate TOC from document head… - #10995

Open
tsondergaard wants to merge 1 commit into
dotnet:mainfrom
tsondergaard:10994-toc-from-headings
Open

feat(pdf): Add pdfTocSource option to generate TOC from document head…#10995
tsondergaard wants to merge 1 commit into
dotnet:mainfrom
tsondergaard:10994-toc-from-headings

Conversation

@tsondergaard

Copy link
Copy Markdown

…ings

Add new configuration options to control PDF Table of Contents source:

  • pdfTocSource: 'toc' (default) or 'headings' to extract from document content
  • pdfTocHeadingDepth: maximum heading level to include (1-6, default 3)

When pdfTocSource is set to 'headings', the PDF TOC is generated by extracting h1-h6 headings from the rendered HTML pages instead of using the toc.yml structure. This is particularly useful for print-style publications using docfx for markdown-to-PDF generation, where the TOC should reflect the document's internal heading structure rather than website navigation.

Fixes #10994

@tsondergaard

Copy link
Copy Markdown
Author

@dotnet-policy-service agree

@tsondergaard

Copy link
Copy Markdown
Author

@yufeih, I see in the pull request history that you are the most active reviewer recently for this repo. Could you have a look at my PR or maybe point me to another suitable reviewer?

@tsondergaard
tsondergaard force-pushed the 10994-toc-from-headings branch from 9ff6562 to dbee2b9 Compare February 21, 2026 11:07
…ings

Add new configuration options to control PDF Table of Contents source:
- pdfTocSource: 'toc' (default) or 'headings' to extract from document content
- pdfTocHeadingDepth: maximum heading level to include (1-6, default 3)

When pdfTocSource is set to 'headings', the PDF TOC is generated by
extracting h1-h6 headings from the rendered HTML pages instead of using
the toc.yml structure. This is particularly useful for print-style
publications using docfx for markdown-to-PDF generation, where the TOC
should reflect the document's internal heading structure rather than
website navigation.

Fixes dotnet#10994
@tsondergaard
tsondergaard force-pushed the 10994-toc-from-headings branch from dbee2b9 to 9d6134e Compare February 23, 2026 17:48
@tsondergaard

Copy link
Copy Markdown
Author

@filzrev, #10005 lists you as an active participant of this project. Could you have a look at my PR?

@filzrev
filzrev requested a review from yufeih May 13, 2026 03:18
@e212156822000

Copy link
Copy Markdown

Hi @tsondergaard , @yufeih,
Thank you for all your contribution. I just tested this feature in my local machine. It works like a charm.
I really hope this feature can get merged to the main branch.
image

p.s. The title sequence in my screenshot is generated by vs code extension 'markdown all in one'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Option to generate PDF Table of Contents from document headings

2 participants