Closed Evidlo closed 5 years ago
How do you expect it to work? The alt
attribute is a plain string, and obviously you cannot have HTML markup in it.
I should have given more detail. I wrote a TreeProcessor extension (markdown-captions) which puts the markdown image text inside a <figcaption>
where HTML markup is valid:
[ins] In [15]: md = markdown.Markdown(
...: extensions=['mdx_math', 'markdown_captions'],
...: extension_configs = {
...: 'mdx_math': {
...: 'enable_dollar_delimiter': True
...: }
...: }
...: )
[nav] In [16]: md.convert('![$3x + 2$](a.jpg)')
Out[16]: '<p><figure><img src="a.jpg" /><figcaption>3x + 2</figcaption></figure></p>'
So my question is why/where is the <script>
tag getting stripped and how might I fix this?
Thanks, it makes more sense now.
The ImageInlineProcessor calls unescape()
here:
https://github.com/Python-Markdown/markdown/blob/3.1.1/markdown/inlinepatterns.py#L614
And unescape()
removes all markup and leaves only text content:
https://github.com/Python-Markdown/markdown/blob/3.1.1/markdown/inlinepatterns.py#L240
Thanks. I switched my extension to a LinkInlineProcessor and set the priority just above the ImageInlineProcessor and it works now.
I have some Tex that I'd like to put inside an image annotation, like so
I dug down a bit and it seems that
handle_match_inline
is correctly substituting thescript
tag, but this is getting stripped off in a later stage.