-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
links fail for identifiers wrapped in backticks with pymdownx.inlinehilite enabled #34
Comments
|
Sadly the fix isn't something simple priority-based pymdownx anyway uses the same priority as the standard one and that's not it and we need the priority to be lower than that autorefs/src/mkdocs_autorefs/references.py Line 213 in a6e373b
the difference is that pymdownx stashes the html and the standard one doesn't |
Ah actually the built-in one also stashes things, and we are able to detect that one but not this one somehow autorefs/src/mkdocs_autorefs/references.py Lines 88 to 89 in a6e373b
|
It seems to be because the first unescape reveals a second stashed item, this time stored in the HTML stash. We can retrieve the item from the stash, but it was stashed as a string, so we can't use if INLINE_PLACEHOLDER_RE.fullmatch(identifier):
identifier = self.unescape(identifier)
if match := HTML_PLACEHOLDER_RE.fullmatch(identifier):
identifier = self.md.htmlStash.rawHtmlBlocks[int(match.group(1))] # no unstash function that does this?
... # how to get text? For <span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span> Should we load that into an Element tree again? Or use a regex to pick up what's between identifier = "".join(re.findall(r">([^<>]+)<", identifier)) And finally we have to unescape HTML characters: identifier = html.unescape(identifier) |
OK that works well, except that our |
markupsafe striptags would fit perfectly for this task. It even unescapes as well |
Created #40 accordingly (sorry for the snipe) |
No worries, I can add myself as a co-author when squashing (I've spent quite some time investigating and debugging 😅) |
This took me a while to figure out, and it's possible this is a "won't fix", but curious to hear your thoughts on this issue.
I use a number of autorefs in the following format:
I'm not sure if that's officially supported, but it has always worked well for me, making properly hyperlinked text wrapped in
<code>
. I recently installed mkdocs-gallery which broke this behavior, and I eventually tracked it down to the addition ofpymdownx.inlinehilite
to the config. So, with the following config, the above autoref will fail:I tracked that down to this line:
autorefs/src/mkdocs_autorefs/references.py
Lines 56 to 61 in a6e373b
if
pymdownx.inlinehilite
is not included in the config,identifier
will equal'some.identifier'
at that line,re.search
will not match, and the link will be created. Ifinlinehilight
is included though,identifier
will look something like'\x02wzxhzdk:1\x03'
, and the search will hit preventing the link.Is this something that you can imagine a fix for? Or is the
[`some.identifier`][]
syntax just not supported?thanks!
The text was updated successfully, but these errors were encountered: