ICML writer: support custom-style attribute on Table.

Closes #8079.
This commit is contained in:
John MacFarlane 2022-05-18 09:55:22 -07:00
parent 6ea83c185c
commit b8fb79b5c0
2 changed files with 25 additions and 3 deletions

View file

@ -333,8 +333,9 @@ blockToICML opts style (Header lvl (ident, cls, _) lst) =
else ""
in parStyle opts stl ident lst
blockToICML _ _ HorizontalRule = return empty -- we could insert a page break instead
blockToICML opts style (Table _ blkCapt specs thead tbody tfoot) =
let (caption, aligns, widths, headers, rows) = toLegacyTable blkCapt specs thead tbody tfoot
blockToICML opts style (Table attr blkCapt specs thead tbody tfoot) =
let (caption, aligns, widths, headers, rows) =
toLegacyTable blkCapt specs thead tbody tfoot
style' = tableName : style
noHeader = all null headers
nrHeaders = if noHeader
@ -370,8 +371,10 @@ blockToICML opts style (Table _ blkCapt specs thead tbody tfoot) =
[("SingleColumnWidth",tshow $ 500 * w) | w > 0]
let tupToDoc tup = selfClosingTag "Column" $ ("Name",tshow $ fst tup) : colWidths (snd tup)
let colDescs = vcat $ zipWith (curry tupToDoc) [0..nrCols-1] widths
let (_,_,kvs) = attr
let dynamicStyle = fromMaybe "Table" (lookup dynamicStyleKey kvs)
let tableDoc = return $ inTags True "Table" [
("AppliedTableStyle","TableStyle/Table")
("AppliedTableStyle","TableStyle/" <> dynamicStyle)
, ("HeaderRowCount", nrHeaders)
, ("BodyRowCount", tshow nrRows)
, ("ColumnCount", tshow nrCols)

19
test/command/8079.md Normal file
View file

@ -0,0 +1,19 @@
```
% pandoc -f html -t icml
<table custom-style="Foo">
<tr><td>one</td></tr>
</table>
^D
<Table AppliedTableStyle="TableStyle/Foo" HeaderRowCount="0" BodyRowCount="1" ColumnCount="1">
<Column Name="0" />
<Cell Name="0:0" AppliedCellStyle="CellStyle/Cell">
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar">
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
<Content>one</Content>
</CharacterStyleRange>
</ParagraphStyleRange>
</Cell>
</Table>
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TableCaption">
</ParagraphStyleRange>
```