Skip to content

Commit

Permalink
fix: More lenient regex for data-mkdocstrings-identifier
Browse files Browse the repository at this point in the history
First introduced in #188, there's a regression: if something messes with the final HTML before mkdocstrings plugin gets to it, it can't be detected and replaced.
A known case is with 'minify' plugin if it appears before our plugin in the config (which it shouldn't anyway).

So workaround this specific case. Make the attribute quotes optional to also catch minified HTML.
Hard to do much else, though perhaps a warning would make sense.
  • Loading branch information
oprypin committed Dec 19, 2020
1 parent 74e2d8a commit dcfec8e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/mkdocstrings/references.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from markdown.inlinepatterns import REFERENCE_RE, ReferenceInlineProcessor

AUTO_REF_RE = re.compile(r'<span data-mkdocstrings-identifier="(?P<identifier>[^"<>]*)">(?P<title>.*?)</span>')
AUTO_REF_RE = re.compile(r'<span data-mkdocstrings-identifier=("?)(?P<identifier>[^"<>]*)\1>(?P<title>.*?)</span>')
"""
A regular expression to match mkdocstrings' special reference markers
in the [`on_post_page` hook][mkdocstrings.plugin.MkdocstringsPlugin.on_post_page].
Expand Down

0 comments on commit dcfec8e

Please sign in to comment.