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

Conflict with abbreviations, toc extension, and typeset plugin #5579

Closed
4 tasks done
jonaharagon opened this issue May 31, 2023 · 6 comments
Closed
4 tasks done

Conflict with abbreviations, toc extension, and typeset plugin #5579

jonaharagon opened this issue May 31, 2023 · 6 comments
Labels
bug Issue reports a bug 🏆 perfect Issue is of outstanding quality resolved Issue is resolved, yet unreleased if open

Comments

@jonaharagon
Copy link
Sponsor

Context

Updating to the latest mkdocs-material-insiders breaks some tables of contents on our staging site: https://deploy-preview-2177.preview.privacyguides.dev/en/vpn/#ipv6-support

Bug description

In the Table of Contents with the typeset plugin enabled, if there's an abbreviation in a heading, the abbreviation and any subsequent text doesn't get rendered at all.

If the abbreviation is at the very beginning of the header it does show the entire heading text, but the permalink icon gets erroneously included at the end:

NK3dksoRsmGJsQD2

Related links

Reproduction

example.zip

Steps to reproduce

  1. Enable typeset plugin
  2. Enable TOC
  3. Enable abbreviations
  4. Use abbreviation in heading

Browser

No response

Before submitting

@squidfunk
Copy link
Owner

Thanks for reporting. So just to be clear – it works if you downgrade to 9.1.14+insiders-4.35.1, right? If so, it is very likely related to the change added in #5536. /cc @pawamoy.

@squidfunk squidfunk added the needs investigation Issue must be investigated by the maintainers label May 31, 2023
@pawamoy
Copy link
Sponsor Contributor

pawamoy commented May 31, 2023

Thanks for the ping @squidfunk 🙂
I tried locally, reverting the change from #5536, and the issue persists.

@pawamoy
Copy link
Sponsor Contributor

pawamoy commented May 31, 2023

I think typeset's regular expressions are responsible here.

Here is an example heading containing the abbreviation, from OP's repro:

<h2 id="othertext-abbreviation-moretext">
  OtherText <abbr title="Test abbreviation!">Abbreviation</abbr> MoreText
  <a class="headerlink" href="#othertext-abbreviation-moretext" title="Permanent link"></a>
</h2>

The issue is simply that <abbr starts with <a 😅
So title = re.sub(r"<a.*?>.*?<\/a>$", "", title) removes abbreviation tags.
Quick, unfuzzed fix:

-            title = re.sub(r"^<a.*?>(.*?)<\/a>", r"\1", title)
-            title = re.sub(r"<a.*?>.*?<\/a>$", "", title)
+            title = re.sub(r"^<a\s+.*?>(.*?)<\/a>", r"\1", title)
+            title = re.sub(r"<a\s+.*?>.*?<\/a>$", "", title)

@squidfunk
Copy link
Owner

Ah, interesting, thanks for debugging! I'll check that asap!

@squidfunk
Copy link
Owner

Fixed in 72c3d0d5f – I adapted the fix proposed by @pawamoy and made it a little more explicit. Thanks again for the excellent reproduction, that made fixing and checking dead simple. Perfect issue!

@squidfunk squidfunk added bug Issue reports a bug resolved Issue is resolved, yet unreleased if open 🏆 perfect Issue is of outstanding quality and removed needs investigation Issue must be investigated by the maintainers labels May 31, 2023
@squidfunk
Copy link
Owner

Released as part of 9.1.15+insiders-4.35.3!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue reports a bug 🏆 perfect Issue is of outstanding quality resolved Issue is resolved, yet unreleased if open
Projects
None yet
Development

No branches or pull requests

3 participants