Skip to content
Discussion options

You must be logged in to vote

md_in_html requires you to not indent the block elements:

import markdown

MD = """
<table markdown>
<thead markdown>
<tr markdown>
<th markdown>
**Header1**
</th>
<th markdown>
**header2**
</th>
</tr>
</thead>
<tbody markdown>
<tr markdown>
<td markdown>
```
some code
```
</td>
<td markdown>
some `markdown` **text**
</td>
</tr>
</tbody>
</table>
"""

html = markdown.markdown(
    MD,
    extensions=['md_in_html'],
)

print(html)
<table>
<thead>
<tr>
<th>
<strong>Header1</strong>
</th>
<th>
<strong>header2</strong>
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>some code</code>
</td>
<td>
some <code>markdown</code> <strong>text</strong>
</td>
</tr>
</tbody>
</table>

Replies: 1 comment 7 replies

Comment options

alexvoss
Jan 16, 2024
Collaborator Sponsor

You must be logged in to vote
7 replies
@hellt
Comment options

@facelessuser
Comment options

Answer selected by markallasread
@hellt
Comment options

@facelessuser
Comment options

@alexvoss
Comment options

alexvoss Jan 18, 2024
Collaborator Sponsor

@facelessuser
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants