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

Inline elements getting parsed as text when doubly nested #1045

Closed
greenape opened this issue Oct 15, 2020 · 4 comments
Closed

Inline elements getting parsed as text when doubly nested #1045

greenape opened this issue Oct 15, 2020 · 4 comments
Assignees
Labels
bug Bug report. confirmed Confirmed bug report or approved feature request. extension Related to one or more of the included extensions.

Comments

@greenape
Copy link

import markdown
md = markdown.Markdown(extensions=["markdown.extensions.md_in_html"])
test = """
<div markdown="1">
<div>
<img src="" />
<code>Test</code>
<p>Test 2</p>
</div>
</div>
"""
md.convert(test)

Which gives:
'<div>\n<div>\n&lt;img src="" /&gt;\n&lt;code&gt;Test&lt;/code&gt;\n<p>Test 2</p>\n</div>\n</div>'

When I'd expect to get '<div>\n<div>\n<img src="" />\n<code>Test</code>\n<p>Test 2</p>\n</div>\n</div>'.

Happens with 3.3, 3.3.1.

@facelessuser
Copy link
Collaborator

Hmm, it seems the new HTML parser is escaping inline tags for some reason.

@facelessuser
Copy link
Collaborator

Seems like md_in_html subclasses from the new HTML parser, but overrides start tag handling. What it forgets to do is flag whether the content is "raw HTML" as that logic is in the overridden base element's start tag logic.

Doing a quick and dirty patch to add this flagging of "raw HTML" logic to md_in_html, we get the expected results:

<div markdown="1">
<div>
<img src=""/>
<code>Test</code>
<p>Test 2</p>
</div>
</div>

Now, I haven't done much testing on this, but I think I should be able to get this fix in with a couple of other HTML related parse issues.

@facelessuser facelessuser self-assigned this Oct 15, 2020
@waylan waylan added bug Bug report. confirmed Confirmed bug report or approved feature request. extension Related to one or more of the included extensions. labels Oct 15, 2020
@facelessuser
Copy link
Collaborator

The cause isn't quite right, but there is some inline handling logic missing. I'll spend some time narrowing it down.

facelessuser added a commit to facelessuser/markdown that referenced this issue Oct 15, 2020
@facelessuser
Copy link
Collaborator

This case has a solution in #1044.

@waylan waylan closed this as completed in 2766698 Oct 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug report. confirmed Confirmed bug report or approved feature request. extension Related to one or more of the included extensions.
Projects
None yet
Development

No branches or pull requests

3 participants