Skip to content

Commit 2ab4df1

Browse files
feat: enable mixed markdown and HTML header IDs (#806)
* feat: enable mixed markdown and HTML header IDs This enables markdown2's `mixed=True` setting of the header-ids extra. * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent ea2b69a commit 2ab4df1

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
## Unreleased: pdoc next
66

7+
- Include included HTML headers in the ToC by default by enabling markdown2's `mixed=True` option of the `header-ids` extra
8+
(#806, @mrossinek)
79

810
## 2025-04-21: pdoc 15.0.3
911

pdoc/render_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"cuddled-lists": None,
6262
"fenced-code-blocks": {"cssclass": formatter.cssclass},
6363
"footnotes": None,
64-
"header-ids": None,
64+
"header-ids": {"mixed": True, "prefix": None, "reset-count": True},
6565
"link-patterns": None,
6666
"markdown-in-html": None,
6767
"mermaid": None,

test/test_render_helpers.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,22 @@ def test_markdown_toc():
110110
assert to_html("#foo\n#bar").toc_html # type: ignore
111111

112112

113+
def test_mixed_toc():
114+
"""
115+
markdown2 can handle mixed markdown and HTML headings.
116+
117+
Let's test that this works as expected.
118+
"""
119+
expected = [
120+
"<ul>",
121+
' <li><a href="#foo">foo</a></li>',
122+
' <li><a href="#bar">bar</a></li>',
123+
"</ul>",
124+
"",
125+
]
126+
assert to_html("#foo\n<h1>bar</h1>").toc_html == "\n".join(expected)
127+
128+
113129
@pytest.mark.parametrize(
114130
"md,html",
115131
[

0 commit comments

Comments
 (0)