File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
crates/quarto-markdown-pandoc
src/pandoc/treesitter_utils
tests/pandoc-match-corpus/markdown Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -180,6 +180,27 @@ pub fn process_pipe_table(
180180 panic ! ( "Unexpected node in pipe_table: {}" , node) ;
181181 }
182182 }
183+
184+ // Check if header row has all empty cells
185+ let header_is_empty = header. as_ref ( ) . map_or ( false , |h| {
186+ h. cells . iter ( ) . all ( |cell| {
187+ cell. content . iter ( ) . all ( |block| {
188+ if let Block :: Plain ( plain) = block {
189+ plain. content . is_empty ( )
190+ } else {
191+ false
192+ }
193+ } )
194+ } )
195+ } ) ;
196+
197+ // If header is empty, discard it and use empty thead
198+ let ( thead_rows, body_rows) = if header_is_empty {
199+ ( vec ! [ ] , rows)
200+ } else {
201+ ( vec ! [ header. unwrap( ) ] , rows)
202+ } ;
203+
183204 PandocNativeIntermediate :: IntermediateBlock ( Block :: Table ( Table {
184205 attr,
185206 caption : Caption {
@@ -189,13 +210,13 @@ pub fn process_pipe_table(
189210 colspec,
190211 head : TableHead {
191212 attr : empty_attr ( ) ,
192- rows : vec ! [ header . unwrap ( ) ] ,
213+ rows : thead_rows ,
193214 } ,
194215 bodies : vec ! [ TableBody {
195216 attr: empty_attr( ) ,
196217 rowhead_columns: 0 ,
197218 head: vec![ ] ,
198- body: rows ,
219+ body: body_rows ,
199220 } ] ,
200221 foot : TableFoot {
201222 attr : empty_attr ( ) ,
Original file line number Diff line number Diff line change 1+ | | |
2+ | -| -|
3+ | a| b|
You can’t perform that action at this time.
0 commit comments