Replies: 1 comment
-
For now, I've found a workaround which doesn't need extra CSS using the HTML Block Extension.
This will render a Then, we can configure document$.subscribe(function() {
var tables = document.querySelectorAll("article div.table-sortable table")
tables.forEach(function(table) {
new Tablesort(table)
})
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Following the documentation in Sortable tables, the selector
article table:not([class])
enablestablesort
in all Markdown tables, since no class can be specified.The same selector is used to style tables in the page.
mkdocs-material/src/templates/assets/stylesheets/main/_typeset.scss
Lines 450 to 458 in 92bb867
It works perfectly as long as you want to enable
tablesort
in all Markdown tables but, how would you enabletablesort
just to some of them?I've thought of using a
class="sortable"
could be a solution, but then, styles are not rendered since in only works for tables without a class.I can solve it in my custom theme by copying the styles to another class selector, but I'm writing this so maybe we can think of a solution that might benefit other users without the need of a custom theme or extra CSS.
I've thought that one possible solution to this would be adding another selector to the CSS rule with a Material for Mkdocs class, for example,
md-datatable
. Then, I would be able to style and sort a table withclass="md-datatable sortable"
.Additional question:
Has anyone been able to enable just some sortable tables only using Markdown?
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions