File tree Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,7 @@ import("./quarto-finalize/typst.lua")
9898
9999import (" ./normalize/flags.lua" )
100100import (" ./normalize/normalize.lua" )
101+ import (" ./normalize/pandoc-tables.lua" )
101102import (" ./normalize/parsehtml.lua" )
102103import (" ./normalize/extractquartodom.lua" )
103104import (" ./normalize/astpipeline.lua" )
Original file line number Diff line number Diff line change @@ -22,6 +22,9 @@ function quarto_ast_pipeline()
2222 }
2323 end
2424 return {
25+ -- identify pandoc table
26+ { name = " normalize-pandoc-table" , filter = pandoc_tables () },
27+
2528 { name = " normalize-table-merge-raw-html" , filter = table_merge_raw_html () },
2629
2730 -- this filter can't be combined with others because it's top-down processing.
Original file line number Diff line number Diff line change 1+ -- pandoc-tables.lua
2+ -- Copyright (C) 2024 Posit Software, PBC
3+
4+ -- Add back classes 'odd', (or 'header' in table header) / 'even' to table rows
5+ -- They were removed in pandoc 3.2.1 but are useful for styling pandoc processed tables
6+ -- Quarto detects .odd class
7+ function pandoc_tables ()
8+ local function add_odd_even (rows , odd )
9+ odd = odd or ' odd'
10+ for rownum , row in ipairs (rows ) do
11+ row .classes :insert ((rownum % 2 ) == 0 and ' even' or odd )
12+ end
13+ return rows
14+ end
15+
16+ return {
17+ Table = function (tbl )
18+ add_odd_even (tbl .head .rows , ' header' )
19+ for _ , tblbody in ipairs (tbl .bodies ) do
20+ add_odd_even (tblbody .body )
21+ end
22+ add_odd_even (tbl .foot .rows )
23+ return tbl
24+ end
25+ }
26+ end
You can’t perform that action at this time.
0 commit comments