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

Strip tags from nav item titles #1072

Closed
wilhelmer opened this issue Apr 15, 2019 · 4 comments
Closed

Strip tags from nav item titles #1072

wilhelmer opened this issue Apr 15, 2019 · 4 comments

Comments

@wilhelmer
Copy link
Sponsor Contributor

@wilhelmer wilhelmer commented Apr 15, 2019

For better readability, I have added manual line breaks to some of my topic titles in mkdocs.yml. Example:

- Software Installation <br>(Windows 10): software-installation-(windows-10).md

This is rendered as follows:

<a href="software-installation-(windows-10).html" title="Software Installation <br>(Windows 10)" class="md-nav__link">
      Software Installation <br>(Windows 10)
</a>

I think the <br> tag shouldn't be included in the title. I had some issues with that when reading the title in my custom JS files.

Suggestion

Add striptags to the item titles in nav-item.html:

<a href="{{ nav_item.url | url }}" title="{{ nav_item.title | striptags }}" class="md-nav__link">
  {{ nav_item.title }}
</a>
@squidfunk
Copy link
Owner

@squidfunk squidfunk commented Apr 15, 2019

Thanks for reporting. Do you have a screenshot how it looks? Also, is striptags generally available in Jinja? Just for a quick comparison.

@wilhelmer
Copy link
Sponsor Contributor Author

@wilhelmer wilhelmer commented Apr 15, 2019

Screenshot (nav entry + title tooltip)
nav-item-tags

"striptags" in the official Jinja documentation
http://jinja.pocoo.org/docs/2.10/templates/#filters
http://jinja.pocoo.org/docs/2.10/templates/#striptags

@squidfunk
Copy link
Owner

@squidfunk squidfunk commented Apr 15, 2019

Perfect, care to submit a PR? I can merge it directly and prepare a release.

@squidfunk
Copy link
Owner

@squidfunk squidfunk commented Apr 16, 2019

Released as part of 4.1.2.

@squidfunk squidfunk closed this Apr 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants