git.iko.soy/typeable/pandoc
on master help sign in
Markdown writer: don't emit a simple table if `simple_tables` disabled.
438e868John MacFarlane
src/Text/Pandoc/Writers/Markdown.hs+9−9
@@ -555,14 +555,14 @@ blockToMarkdown' opts t@(Table caption aligns widths headers rows) = do
555 case True of
555 case True of
556 _ | isSimple &&
556 _ | isSimple &&
557 isEnabled Ext_simple_tables opts -> fmap (nest 2,) $
557 isEnabled Ext_simple_tables opts -> fmap (nest 2,) $
558− pandocTable opts (all null headers) aligns' widths'
558+ pandocTable opts False (all null headers) aligns' widths'
559 rawHeaders rawRows
559 rawHeaders rawRows
560 | isSimple &&
560 | isSimple &&
561 isEnabled Ext_pipe_tables opts -> fmap (id,) $
561 isEnabled Ext_pipe_tables opts -> fmap (id,) $
562 pipeTable (all null headers) aligns' rawHeaders rawRows
562 pipeTable (all null headers) aligns' rawHeaders rawRows
563 | not hasBlocks &&
563 | not hasBlocks &&
564 isEnabled Ext_multiline_tables opts -> fmap (nest 2,) $
564 isEnabled Ext_multiline_tables opts -> fmap (nest 2,) $
565− pandocTable opts (all null headers) aligns' widths'
565+ pandocTable opts True (all null headers) aligns' widths'
566 rawHeaders rawRows
566 rawHeaders rawRows
567 | isEnabled Ext_grid_tables opts &&
567 | isEnabled Ext_grid_tables opts &&
568 writerColumns opts >= 8 * numcols -> (id,) <$>
568 writerColumns opts >= 8 * numcols -> (id,) <$>
@@ -633,9 +633,10 @@ pipeTable headless aligns rawHeaders rawRows = do
633 let body = vcat $ map torow rawRows
633 let body = vcat $ map torow rawRows
634 return $ header $$ border $$ body
634 return $ header $$ border $$ body
635
635
636+pandocTable :: PandocMonad m
636−pandocTable :: PandocMonad m => WriterOptions -> Bool -> [Alignment] -> [Double]
637+ => WriterOptions -> Bool -> Bool -> [Alignment] -> [Double]
637 -> [Doc] -> [[Doc]] -> MD m Doc
638 -> [Doc] -> [[Doc]] -> MD m Doc
638−pandocTable opts headless aligns widths rawHeaders rawRows = do
639+pandocTable opts multiline headless aligns widths rawHeaders rawRows = do
639 let isSimple = all (==0) widths
640 let isSimple = all (==0) widths
640 let alignHeader alignment = case alignment of
641 let alignHeader alignment = case alignment of
641 AlignLeft -> lblock
642 AlignLeft -> lblock
@@ -664,10 +665,9 @@ pandocTable opts headless aligns widths rawHeaders rawRows = do
664 (zipWith3 alignHeader aligns widthsInChars)
665 (zipWith3 alignHeader aligns widthsInChars)
665 let rows' = map makeRow rawRows
666 let rows' = map makeRow rawRows
666 let head' = makeRow rawHeaders
667 let head' = makeRow rawHeaders
667− let maxRowHeight = maximum $ map height (head':rows')
668 let underline = cat $ intersperse (text " ") $
668 let underline = cat $ intersperse (text " ") $
669 map (\width -> text (replicate width '-')) widthsInChars
669 map (\width -> text (replicate width '-')) widthsInChars
670− let border = if maxRowHeight > 1
670+ let border = if multiline
671 then text (replicate (sum widthsInChars +
671 then text (replicate (sum widthsInChars +
672 length widthsInChars - 1) '-')
672 length widthsInChars - 1) '-')
673 else if headless
673 else if headless
@@ -676,9 +676,9 @@ pandocTable opts headless aligns widths rawHeaders rawRows = do
676 let head'' = if headless
676 let head'' = if headless
677 then empty
677 then empty
678 else border <> cr <> head'
678 else border <> cr <> head'
679− let body = if isSimple
679+ let body = if multiline
680− then vcat rows'
680+ then vsep rows'
681− else vsep rows'
681+ else vcat rows'
682 let bottom = if headless
682 let bottom = if headless
683 then underline
683 then underline
684 else border
684 else border
test/command/3529.mdnew file+15
@@ -0,0 +1,15 @@
1+```
2+% pandoc -t markdown-simple_tables-pipe_tables-grid_tables+multiline_tables
3+A B
4+-- --
5+7 8
6+9 10
7+^D
8+ --------
9+ A B
10+ --- ----
11+ 7 8
12+
13+ 9 10
14+ --------
15+```