Skip to content
Discussion options

You must be logged in to vote

Unfortunately, attr_list won't work with tables. One possibility is using the pymdownx.blocks.html extension. That is if you find the syntax more attractive than raw HTML

The below example wraps the table in a div with the specified class:

import markdown

md = """
/// html | div.class
col1  | col2
----- | ----
cell1 | cell2
///
"""

print(markdown.markdown(md, extensions=['tables', 'pymdownx.blocks.html']))
<div class="class">
<table>
<thead>
<tr>
<th>col1</th>
<th>col2</th>
</tr>
</thead>
<tbody>
<tr>
<td>cell1</td>
<td>cell2</td>
</tr>
</tbody>
</table>
</div>

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by hudsondiegof
Comment options

You must be logged in to vote
1 reply
@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
2 participants