Skip to content

Determined nav/heading title includes attribute list when only referencing via file instead giving manually title (Should not if attr_list extension enabled) #3136

Closed
@hendrikp

Description

@hendrikp

I'm using the attr_list markdown extension to provide language neutral anchor's so I can define/reference each language section with the same anchor ids. This works great for the autogenerated TOC, the markdown links, images and more.

One thing that doesn't work is the autogenerated heading text (neither when specifying file, nor when using wildcard nav plugins, or when autoincluding the full doc dir).

It results in the following headings being generated in the sample provided below:

  • in German doc Hallo Welt { #introduction } linking to the correct md/html file, should be just Hallo Welt
  • in English doc Hello World { #introduction } linking to the correct md/html file, should be just Hello World

My suggestion would be to substitute the regexp-pattern \s*?\{.*?\}\s*?$ from the determined heading texts for the nav+page title if the attr_list plugin is enabled (or in general). This would exclude/remove all attributes from a heading (a more advanced version could maybe retain the attribute class etc, but not really needed).

I will see if i can submit a MR.

mkdocs.yml

docs_dir: docs/en

nav:
  - somefile.md

markdown_extensions:
   - attr_list

docs/en/somefile.md

# Hello World { #introduction }

Test

mkdocs.de.yml

docs_dir: docs/de

nav:
  - somefile.md

markdown_extensions:
   - attr_list

docs/de/somefile.md

# Hallo Welt { #introduction }

Test

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions