Closed zendern closed 2 months ago
You are probably looking for https://python-markdown.github.io/extensions/md_in_html/ which allows you to parse Markdown in HTML block elements.
💯 idk how i missed that one. But confirmed it does work as expected. Thank you @facelessuser. This can be closed.
Usecase
I have a markdown file that I want to transform to html using this library. When I have content that is inside of a
<details>
block it does not render correctly.Example
Markdown File
``` ## Inside Details/Summary block (DOES NOT RENDER)My summary
| Operation | Types | Subtypes | Additional info | |----------------------------|---------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------| | **Prepare Solutions** | PREPARE_SOLUTIONS | - | - |Preview of the rendered Markdown in VSCode
Rendered Output by Python-Markdown
```htmlMy summary
| Operation | Types | Subtypes | Additional info | |----------------------------|---------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------| | **Prepare Solutions** | PREPARE_SOLUTIONS | - | - |Code to generate this html
```python import markdown # read a file to a string with open('example.md', 'r') as file: your_text_string = file.read() html = markdown.markdown(your_text_string, extensions=[ "admonition", "markdown.extensions.tables", "markdown.extensions.fenced_code", "pymdownx.magiclink", "pymdownx.tilde", "sane_lists", ],) print(html) ```Attempted fixes
I thought maybe if i wrapped the table that is inside of the in a tag it might render it. Tried
<div>
and<p>
but neither helped. From looking at the code i think its likely due todetails
being listed as a Block level element and its to not be touched so rendering never happens.https://github.com/Python-Markdown/markdown/blob/fc74d69758ff288e26ff616c703b22ce5a02a68a/markdown/util.py#L47-L58