Skip to content
Permalink
Browse files

fix: More lenient regex for data-mkdocstrings-identifier

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 dcfec8edfdff050debc5856dfc213d3119a84792
Showing with 1 addition and 1 deletion.
  1. +1 −1 src/mkdocstrings/references.py
@@ -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].

0 comments on commit dcfec8e

Please sign in to comment.