items list not rendered correctly to HTML
Closed this issue · 2 comments
abdilahsamari100 commented
When converting Markdown
to HTML
, lists are not properly rendered the sub-items under each main item
The nested sub-items should appear inside the respective parent <ul>
tags, maintaining the correct list hierarchy.
import markdown
markdown_text = """
- **Visual Narration**: Description here
- **Story Arcs and Pacing**:
- Sub-item 1
- Sub-item 2"""
# Convert Markdown to HTML
html_output = markdown.markdown(markdown_text, extensions=['extra'], output_format="html")
# Print the HTML result
print(html_output)
Expected :
Actual :
How i can solve this problem please?
facelessuser commented
If you want to have nested lists, they need to be indented 4 spaces (or 1 tab). You can read further about this here and how to change if you feel so inclined: https://python-markdown.github.io/#differences.
import markdown
print(f'Markdown Version: {markdown.__version__}')
print('-----')
MD = """
- **Visual Narration**: Description here
- **Story Arcs and Pacing**:
- Sub-item 1
- Sub-item 2
"""
extensions = ["extra"]
extension_configs = {}
print(markdown.markdown(MD, extensions=extensions, extension_configs=extension_configs))
Results
Markdown Version: 3.7
-----
<ul>
<li><strong>Visual Narration</strong>: Description here</li>
<li><strong>Story Arcs and Pacing</strong>:<ul>
<li>Sub-item 1</li>
<li>Sub-item 2</li>
</ul>
</li>
</ul>
abdilahsamari100 commented
@facelessuser thanks