markdown
markdown copied to clipboard
Feature Request: Render contents that are inside `<details><summary>` block
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)
<details>
<summary><b>My summary</b></summary>
| Operation | Types | Subtypes | Additional info |
|----------------------------|---------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------|
| **Prepare Solutions** | PREPARE_SOLUTIONS | - | - |
</details>
## Outside of details/summary block (RENDERS CORRECTLY)
| Operation | Types | Subtypes | Additional info |
|----------------------------|---------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------|
| **Prepare Solutions** | PREPARE_SOLUTIONS | - | - |
Preview of the rendered Markdown in VSCode
Rendered Output by Python-Markdown
<details>
<summary><b>My summary</b></summary>
| Operation | Types | Subtypes | Additional info |
|----------------------------|---------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------|
| **Prepare Solutions** | PREPARE_SOLUTIONS | - | - |
</details>
<table>
<thead>
<tr>
<th>Operation</th>
<th>Types</th>
<th>Subtypes</th>
<th>Additional info</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Prepare Solutions</strong></td>
<td>PREPARE_SOLUTIONS</td>
<td>-</td>
<td>-</td>
</tr>
</tbody>
</table>
Code to generate this html
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 to details 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