Skip to content
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

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 opened this issue Mar 4, 2023 · 0 comments · Fixed by #3191

Comments

@hendrikp
Copy link
Contributor

hendrikp commented Mar 4, 2023

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
@hendrikp hendrikp changed the title Determined nav/heading title includes attribute list when only referencing via file instead giving manually title (When attr_list extension enabled) Determined nav/heading title includes attribute list when only referencing via file instead giving manually title (Should not if attr_list extension enabled) Mar 4, 2023
@oprypin oprypin closed this as completed Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants