From b8fb79b5c0d3d2dc07f321e633d6b24a800ef130 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 18 May 2022 09:55:22 -0700 Subject: [PATCH] ICML writer: support custom-style attribute on Table. Closes #8079. --- src/Text/Pandoc/Writers/ICML.hs | 9 ++++++--- test/command/8079.md | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 test/command/8079.md diff --git a/src/Text/Pandoc/Writers/ICML.hs b/src/Text/Pandoc/Writers/ICML.hs index 8d75bb7df..7f0c4d5a7 100644 --- a/src/Text/Pandoc/Writers/ICML.hs +++ b/src/Text/Pandoc/Writers/ICML.hs @@ -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) diff --git a/test/command/8079.md b/test/command/8079.md new file mode 100644 index 000000000..a6adf491d --- /dev/null +++ b/test/command/8079.md @@ -0,0 +1,19 @@ +``` +% pandoc -f html -t icml + + +
one
+^D + + + + + + one + + + +
+ + +```