Replies: 3 comments 14 replies
-
Customise the CSS for your own needs. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
This seems to work: -- table-class.lua
function Div(div)
klass = div.attributes["table-class"]
if klass ~= nil then
return div:walk {
Table = function(tbl)
tbl.classes = { klass }
tbl.attributes.style = ""
return tbl
end,
Tr = function(tr)
tr.classes.remove("odd")
tr.classes.remove("even")
return tr
end
}
end
end ---
title: just testing
filters:
- table-class.lua
---
| | | | | | | | | | | | | | |
|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
| | | | | | | | 1 | | | | | | |
| | | | | | | 1 | | 1 | | | | | |
| | | | | | 1 | | 2 | | 1 | | | | |
| | | | | 1 | | 3 | | 3 | | 1 | | | |
| | | | 1 | | 4 | | 6 | | 4 | | 1 | | |
| | | 1 | | 5 | | 10 | | 10 | | 5 | | 1 | |
| | 1 | | 6 | | 15 | | 20 | | 15 | | 6 | | 1 |
:::{table-class="table-sm"}
| | | | | | | | | | | | | | |
|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
| | | | | | | | 1 | | | | | | |
| | | | | | | 1 | | 1 | | | | | |
| | | | | | 1 | | 2 | | 1 | | | | |
| | | | | 1 | | 3 | | 3 | | 1 | | | |
| | | | 1 | | 4 | | 6 | | 4 | | 1 | | |
| | | 1 | | 5 | | 10 | | 10 | | 5 | | 1 | |
| | 1 | | 6 | | 15 | | 20 | | 15 | | 6 | | 1 |
::: The trick is to remove the https://github.com/quarto-dev/quarto-cli/blob/5ad49f1/src/format/html/format-html-bootstrap.ts#L308 However, then the table has a style attribute added by Pandoc that defeats the styling. Ordinarily it is removed by that postprocessor but now I need to do it myself. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
In many cases, I find that the Bootstrap default
table
class has too much whitespace. The Bootstrap classtable-sm
would suit better, but is there any way to use that class for Markdown tables?I found a Pandoc discussion where it is mentioned that Pandoc doesn't currently have a way to specify table classes in Markdown, and that the easiest route would be to post-process the HTML. Indeed the following solution (run after quarto) is somewhat hacky but works, but I would prefer something that lets me control the class in the Markdown source.
Beta Was this translation helpful? Give feedback.
All reactions