Markdown in HTML renders in snippets when used within tabs, but not in normal markdown. Why? #2188
-
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This has to do with how Python Markdown, not Tabs parses Markdown. Generally, Python Markdown requires block tags (like <div>
**content**
</div> To parse the content as Markdown, you need to use the <div markdown>
**content**
</div> While the Python Markdown documentation does not explain this well, these cases are meant for root-level HTML. This can cause inconsistencies when we are using HTML that is not at the root level; for instance, in indented constructs. When we use this under indented constructs it appears the Markdown parser treats it all as inline HTML and parses the Markdown content. MD = """
- Test
<div>
**content**
</div>
<div markdown>
**content**
</div>
"""
import markdown
print(markdown.markdown(MD)) <ul>
<li>
<p>Test</p>
<p><div>
<strong>content</strong>
</div></p>
<p><div markdown>
<strong>content</strong>
</div></p>
</li>
</ul> I'm personally not a fan of how this is handled in Python Markdown, but I also haven't had the time to dig into the current HTML parser logic Python Markdown to see how easily we could alter the logic to get consistent handling. So, to answer your question as to why there is an inconsistency, it is because that is how Python Markdown handles HTML. It has nothing to do with Tabs. |
Beta Was this translation helpful? Give feedback.
This has to do with how Python Markdown, not Tabs parses Markdown.
Generally, Python Markdown requires block tags (like
<div>
) to have the start and end on different lines, but this will not automatically parse the HTML content as Markdown.To parse the content as Markdown, you need to use the
md_in_html
extension and apply the markdown attribute:While the Python Markdown documentation does not explain this well, these cases are meant for root-level HTML. This can cause inconsistencies when we are using HTML that is not at the root level; for instance, in indented constructs.
When we use this under indented constructs it appears …