pandoc
pandoc copied to clipboard
HTML reader: width on style attribute of table does not influence column widths
Explain the problem.
command: pandoc --output --to docx reference-doc=custom-reference.docx report-8660595912627799385.html
Pandoc version? pandoc.exe 2.14.2 windows
When table has inline style width: 100%
as in the second table I expect the docx table to have full width, i.e.
I think the key is <w:tblW w:w="5000" w:type="pct" />
However, currently the resulting layout autofits the contents of the table cells, and is not full width.
does it also happen without reference-doc=custom-reference.docx
?
This has nothing to do with docx specifically. You can reproduce using -f html -t native
, giving the following representation of the table:
, Table
( ""
, []
, [ ( "style"
, "border-collapse: collapse; width: 99.5575%; height: 22px;"
)
, ( "border" , "1" )
]
)
(Caption Nothing [])
[ ( AlignDefault , ColWidthDefault )
, ( AlignDefault , ColWidthDefault )
]
(TableHead ( "" , [] , [] ) [])
[ TableBody
( "" , [] , [] )
(RowHeadColumns 0)
[]
[ Row
( "" , [] , [ ( "style" , "height: 22.3984px;" ) ] )
[ Cell
( ""
, []
, [ ( "style" , "width: 50.0443%; height: 22.3984px" ) ]
)
AlignDefault
(RowSpan 1)
(ColSpan 1)
[ Plain [ Str "Aa" ] ]
, Cell
( ""
, []
, [ ( "style" , "width: 50.0443%; height: 22.3984px" ) ]
)
AlignDefault
(RowSpan 1)
(ColSpan 1)
[ Plain [ Str "Bbb" ] ]
]
, Row
( "" , [] , [ ( "style" , "height: 22.3984px;" ) ] )
[ Cell
( ""
, []
, [ ( "style" , "width: 50.0443%; height: 22.3984px" ) ]
)
AlignDefault
(RowSpan 1)
(ColSpan 1)
[]
, Cell
( ""
, []
, [ ( "style" , "width: 50.0443%; height: 22.3984px" ) ]
)
AlignDefault
(RowSpan 1)
(ColSpan 1)
[]
]
]
]
(TableFoot ( "" , [] , [] ) [])
]
As you can see, the style information is included in an attribute. But it isn't taken account of in determining the column widths, since we have:
[ ( AlignDefault , ColWidthDefault )
, ( AlignDefault , ColWidthDefault )
It would be possible to modify the HTML reader to look at the width component of the style attribute and use this in computing widths. In this case, though, we'd have to set both columns to 0.5 full width, since there isn't other information here about the relative widths to use.
Is this issue planned to be resolved in the near future? and is there a fix or trick to specify the width of table cells?
You can use <col>
elements with relative widths.