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

HTML tags that are display:block by default are messed up when multiline #342

Open
ghost opened this issue Jan 26, 2020 · 1 comment
Open
Labels

Comments

@ghost
Copy link

ghost commented Jan 26, 2020

Certain HTML tags when messed up when multiline, and as far as I can tell it's the ones that are display:block by default.

Found on v2.3.6, installed from the FreeBSD py37-markdown2 port; I checked out the repo and ran v2.3.8 to make sure and it was not fixed.

Testcases (I use <wc> because I originally ran into this with a custom web component):


<wc>
<div>
</div>
</wc>

Produces (incorrect):

<p><wc></p>

<div>
</div>

<p></wc></p>

<wc>  
<pre>
</pre>
</wc>

Produces (incorrect):

<p><wc></p>

<pre>
</pre>

<p></wc></p>

<wc>
<h1>
</h1>
</wc>

Produces (incorrect):

<p><wc></p>

<h1>
</h1>

<p></wc></p>

<wc>
<span>
</span>
</wc>

Produces (correct):

<p><wc>
<span>
</span>
</wc></p>

<wc>
<invalid>
</invalid>
</wc>

Produces (correct):

<p><wc>
<invalid>
</invalid>
</wc></p>
@ghost
Copy link
Author

ghost commented Jan 26, 2020

Update: I just read the source and understood why this happens: block-level elements are separated from the markdown around them while my custom element is assumed to be an inline element, so it's always either cuddled to the previous paragraph or set as a paragraph on its own, even if there's no blank line between it and the code block. Unfortunately, it's not easy to work around it by making a subclass that adds the tag names of block-level custom elements to Markdown._block_tags_a and Markdown._block_tags_b, because _strict_tag_block_re and _liberal_tag_block_re will already be computed and won't be affected by the change. For now, I'm editing the source, but I think this package should have a way to do this from the outside. If there isn't already a good way I'm missing, and @trentm agrees, I would volunteer to add it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant