aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/CommonMark.hs
diff options
context:
space:
mode:
authordespresc <christian.j.j.despres@gmail.com>2020-04-04 16:35:42 -0400
committerdespresc <christian.j.j.despres@gmail.com>2020-04-15 23:03:22 -0400
commit4e34d366df31937cdc69b6b366355f10a84c16b2 (patch)
tree844503b0f59439acaec5d2f8e2f016e2eb1d214c /src/Text/Pandoc/Readers/CommonMark.hs
parentf8ce38975b547fe7fc8c12ccee3a940b35d8b9cf (diff)
downloadpandoc-4e34d366df31937cdc69b6b366355f10a84c16b2.tar.gz
Adapt to the newest Table type, fix some previous adaptation issues
- Writers.Native is now adapted to the new Table type. - Inline captions should now be conditionally wrapped in a Plain, not a Para block. - The toLegacyTable function now lives in Writers.Shared.
Diffstat (limited to 'src/Text/Pandoc/Readers/CommonMark.hs')
-rw-r--r--src/Text/Pandoc/Readers/CommonMark.hs12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Readers/CommonMark.hs b/src/Text/Pandoc/Readers/CommonMark.hs
index 33afbe59f..d1f732bf1 100644
--- a/src/Text/Pandoc/Readers/CommonMark.hs
+++ b/src/Text/Pandoc/Readers/CommonMark.hs
@@ -111,13 +111,19 @@ addBlock opts (Node _ (LIST listAttrs) nodes) =
PAREN_DELIM -> OneParen
exts = readerExtensions opts
addBlock opts (Node _ (TABLE alignments) nodes) =
- (Table nullAttr (Caption Nothing []) (zip aligns widths) 0 headers rows [] :)
+ (Table
+ nullAttr
+ (Caption Nothing [])
+ (zip aligns widths)
+ (TableHead nullAttr headers)
+ [TableBody nullAttr 0 [] rows]
+ (TableFoot nullAttr []) :)
where aligns = map fromTableCellAlignment alignments
fromTableCellAlignment NoAlignment = AlignDefault
fromTableCellAlignment LeftAligned = AlignLeft
fromTableCellAlignment RightAligned = AlignRight
fromTableCellAlignment CenterAligned = AlignCenter
- widths = replicate numcols Nothing
+ widths = replicate numcols ColWidthDefault
numcols = if null rows'
then 0
else maximum $ map rowLength rows'
@@ -136,7 +142,7 @@ addBlock opts (Node _ (TABLE alignments) nodes) =
| isBlockNode n = fromSimpleCell $ addBlocks opts (n:ns)
| otherwise = fromSimpleCell [Plain (addInlines opts (n:ns))]
toCell (Node _ t _) = error $ "toCell encountered non-cell " ++ show t
- fromSimpleCell = Cell nullAttr Nothing 1 1
+ fromSimpleCell = Cell nullAttr AlignDefault 1 1
rowLength (Row _ body) = length body -- all cells are 1×1
addBlock _ (Node _ TABLE_ROW _) = id -- handled in TABLE
addBlock _ (Node _ TABLE_CELL _) = id -- handled in TABLE