table attributes #6173
-
Is there a way to customize tables with attributes? Keeping the table in markdown format, but referencing a custom style? Something like:
My project has multiple styles of tables, i don't want to use html to maintain the readability of the .md file. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Unfortunately, The below example wraps the table in a 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> |
Beta Was this translation helpful? Give feedback.
-
Yes, it's very close to what I need. Thanks. |
Beta Was this translation helpful? Give feedback.
Unfortunately,
attr_list
won't work with tables. One possibility is using thepymdownx.blocks.html
extension. That is if you find the syntax more attractive than raw HTMLThe below example wraps the table in a
div
with the specified class: