-
Notifications
You must be signed in to change notification settings - Fork 4k
Closed
Labels
bugIssue reports a bugIssue reports a bugresolvedIssue is resolved, yet unreleased if openIssue is resolved, yet unreleased if open
Description
- I've read the contribution guidelines and agree with them
I've found a bug and checked that ...
- ... the problem doesn't occur with the default MkDocs template
- ... the problem is not in any of my customizations (CSS, JS, template)
- ... the documentation does not mention anything about my problem
- ... there are no open or closed issues that are related to my problem
Description
When appeding a class to an H1 tag with attribute lists, the ToC-hack in the toc.html partial breaks and the first item in the ToC is the page title. The ToC-hack assumes that the first attribute in an H1 is id, but when adding a class to it, class is the first tag.
Expected behavior
When adding a class to an H1 using attribute lists the Page Title should not be in the ToC.
Actual behavior
When adding a class to an H1 using attribute lists the Page Title is the first ToC item.
Steps to reproduce the bug
- Ensure that the
attr_listmarkdown extension is used. - Add a class to the H1 in a
.mdfile with at least one H2:
# This is my title { .myTitleClass }
Text
## This is my first ToC entry
Text
- Run
mkdocs serveand view
Package versions
- Python: 3.9.0
- MkDocs: 1.1.2
- Material: 7.1.1
Project configuration
markdown_extensions:
- attr_listSystem information
N/A
Temporary workaround
A temporary workaround is to add an additional if to the toc.html partial that checks for class:
{% if toc | first is defined and "\x3ch1 class=" in page.content %}
{% set toc = (toc | first).children %}
{% endif %}
Metadata
Metadata
Assignees
Labels
bugIssue reports a bugIssue reports a bugresolvedIssue is resolved, yet unreleased if openIssue is resolved, yet unreleased if open