Closed
Description
Pandoc types has support for row head, see https://pandoc.org/lua-filters.html#type-tablebody, and Microsoft Word allows users to apply "special formatting for the first column", see the "Table Style Options" in the screenshot.
DOCX reader could treat the selection of "special formatting for the first column" as "the first column is a header".
Minimal Working Examples
XML structure
table-2x2-single-header.docx
has
<w:tbl>
<w:tblPr>
<w:tblStyle w:val="GridTable5Dark-Accent1"/>
<w:tblW w:w="0" w:type="auto"/>
<w:tblLook w:val="0420" w:firstRow="1" w:lastRow="0" w:firstColumn="0" w:lastColumn="0" w:noHBand="0" w:noVBand="1"/>
</w:tblPr>
and table-2x2-two-headers.docx
has
<w:tbl>
<w:tblPr>
<w:tblStyle w:val="GridTable5Dark-Accent1"/>
<w:tblW w:w="0" w:type="auto"/>
<w:tblLook w:val="04A0" w:firstRow="1" w:lastRow="0" w:firstColumn="1" w:lastColumn="0" w:noHBand="0" w:noVBand="1"/>
</w:tblPr>
DOCX reader need to check the value of w:firstColumn
in <w:tblLook />
.
Current Reading
pandoc --from docx --to native table-2x2-two-headers.docx
produces
[ Table
( "" , [] , [] )
(Caption Nothing [])
[ ( AlignDefault , ColWidth 0.5 )
, ( AlignDefault , ColWidth 0.5 )
]
(TableHead
( "" , [] , [] )
[ Row
( "" , [] , [] )
[ Cell
( "" , [] , [] )
AlignDefault
(RowSpan 1)
(ColSpan 1)
[ Plain [ Str "1" ] ]
, Cell
( "" , [] , [] )
AlignDefault
(RowSpan 1)
(ColSpan 1)
[ Plain [ Str "2" ] ]
]
])
[ TableBody
( "" , [] , [] )
(RowHeadColumns 0)
[]
[ Row
( "" , [] , [] )
[ Cell
( "" , [] , [] )
AlignDefault
(RowSpan 1)
(ColSpan 1)
[ Plain [ Str "3" ] ]
, Cell
( "" , [] , [] )
AlignDefault
(RowSpan 1)
(ColSpan 1)
[ Plain [ Str "4" ] ]
]
]
]
(TableFoot ( "" , [] , [] ) [])
]
Desired Reading
pandoc --from docx --to native table-2x2-two-headers.docx
should produce
[ Table
( "" , [] , [] )
(Caption Nothing [])
[ ( AlignDefault , ColWidth 0.5 )
, ( AlignDefault , ColWidth 0.5 )
]
(TableHead
( "" , [] , [] )
[ Row
( "" , [] , [] )
[ Cell
( "" , [] , [] )
AlignDefault
(RowSpan 1)
(ColSpan 1)
[ Plain [ Str "1" ] ]
, Cell
( "" , [] , [] )
AlignDefault
(RowSpan 1)
(ColSpan 1)
[ Plain [ Str "2" ] ]
]
])
[ TableBody
( "" , [] , [] )
(RowHeadColumns 1)
[]
[ Row
( "" , [] , [] )
[ Cell
( "" , [] , [] )
AlignDefault
(RowSpan 1)
(ColSpan 1)
[ Plain [ Str "3" ] ]
, Cell
( "" , [] , [] )
AlignDefault
(RowSpan 1)
(ColSpan 1)
[ Plain [ Str "4" ] ]
]
]
]
(TableFoot ( "" , [] , [] ) [])
]
The value of RowHeadColumns
is now 1.
Environment
pandoc --version
returns
pandoc 3.1.11.1
Features: +server +lua
Scripting engine: Lua 5.4
User data directory: /home/raniere/.local/share/pandoc
Copyright (C) 2006-2023 John MacFarlane. Web: https://pandoc.org
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.