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

Nested one-liners broken with md_in_html #1074

Open
git1sal opened this issue Nov 23, 2020 · 3 comments
Open

Nested one-liners broken with md_in_html #1074

git1sal opened this issue Nov 23, 2020 · 3 comments
Labels
bug Bug report. confirmed Confirmed bug report or approved feature request. extension Related to one or more of the included extensions.

Comments

@git1sal
Copy link

git1sal commented Nov 23, 2020

Version 3.3.3. I've found several anomalies in the behavior of nested markdown=1 blocks. Here's one that's probably diagnostic:

markdown.markdown('<div class="outer" markdown="block"><div class="inner" markdown="block">*foo*</div></div>', extensions=["extra"])

returns:

'<p><div class="inner" markdown="block"><div class="outer" markdown="block">*foo*</div></p>\n</div>'

The inner <div> is now outside.

Other weird things in this example are the addition of the <p> tags, which are unmatched, and a stray \n .

@git1sal
Copy link
Author

git1sal commented Nov 23, 2020

Oh, I should have mentioned also that the actual content *foo* does not get markdownized in this test case.

@waylan
Copy link
Member

waylan commented Nov 23, 2020

I'm not able to replicate that behavior in any recent version. With versions 3.3.0 through 3.3.3 I get:

<div class="outer">
<div class="inner">
<p><em>foo</em></p>
</div>
</div>

However, I see that in #1069 (which is part of the unreleased version 3.3.4) we broke this and I am getting:

<div class="outer">
<p><div class="inner" markdown="block"><em>foo</em></p>
</div>
</div>

That does not turn things 'inside-out,' but it is clearly wrong. and it demonstrates again that our tests for md_in_html are incomplete.

By the way, there is a clear difference between the inputs:

<div class="outer" markdown="block">
<div class="inner" markdown="block">*foo*</div>
</div>

... which works fine and ...

<div class="outer" markdown="block"><div class="inner" markdown="block">*foo*</div></div>

... which is broken in the current HEAD of master. The later input is also not something we have in our tests.

The issue is that the nested div does not start at the beginning of a line and therefore is not parsed as a block level element. Under normal circumstances, this would be the correct behavior. However, as it is the first and immediate child of the outer <div> is should still be treated as a block level element. Interestingly, when working on #1069 it occurred to me that this could be an issue, but when the simple fix didn't break any tests, I dismissed the thought. I think we need a more sophisticated manner to determine at_line_start. Sigh.

@waylan waylan changed the title Hierarchy of nested <div markdown=1> gets turned inside-out Nested one-liners broken with md_in_html Nov 23, 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 Nov 23, 2020
@git1sal
Copy link
Author

git1sal commented Nov 24, 2020

Thank you very much—inserting newlines resolved the problem for me.

Thank you for the amazing work you are doing on this package!

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

2 participants