Skip to content

Include HTML headers in ToC #805

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mrossinek opened this issue May 3, 2025 · 3 comments · Fixed by #806
Closed

Include HTML headers in ToC #805

mrossinek opened this issue May 3, 2025 · 3 comments · Fixed by #806

Comments

@mrossinek
Copy link
Contributor

mrossinek commented May 3, 2025

Problem Description

When a docstring includes HTML headers (<h1>, etc.) for example when I used an .. include:: some_file.html (or some markdown file which mixes markdown and HTML headers for some reason) directive, those headers are not included in the table of contents.

Proposal

markdown2 already supports this feature: trentm/python-markdown2#538.
All one would need to do, is set header-ids["mixed"] = True for the header-ids extra, which pdoc already uses.

Additional Context

Essentially, I would consider this the reverse of the markdown-in-html setting, which is already supported by pdoc. So I do not see a reason not to support this.

@mhils
Copy link
Member

mhils commented May 3, 2025

Sure, please send a PR!

@mrossinek
Copy link
Contributor Author

Sure, please send a PR!

Happy to do so! How should I approach this?

  1. Should I simply enable mixed header-ids by default? E.g. through "header-ids": {"mixed": True} here:
    "header-ids": None,
  2. Or should I add a new command-line argument, e.g. --mixed-header-ids which indicates this boolean value? One could leave its default to be False, therefore not changing the current behavior.

@mhils
Copy link
Member

mhils commented May 4, 2025

Definitely 1), we want to keep the CLI surface as small as possible.

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

Successfully merging a pull request may close this issue.

2 participants