diff options
-rw-r--r-- | src/Text/Pandoc/Writers/Markdown.hs | 34 | ||||
-rw-r--r-- | test/command/4061.md | 14 |
2 files changed, 36 insertions, 12 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index a1f30cb0e..a8452f468 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -575,8 +575,6 @@ blockToMarkdown' opts t@(Table caption aligns widths headers rows) = do let padRow r = case numcols - length r of x | x > 0 -> r ++ replicate x empty | otherwise -> r - rawHeaders <- padRow <$> mapM (blockListToMarkdown opts) headers - rawRows <- mapM (fmap padRow . mapM (blockListToMarkdown opts)) rows let aligns' = case numcols - length aligns of x | x > 0 -> aligns ++ replicate x AlignDefault | otherwise -> aligns @@ -586,16 +584,25 @@ blockToMarkdown' opts t@(Table caption aligns widths headers rows) = do (nst,tbl) <- case True of _ | isSimple && - isEnabled Ext_simple_tables opts -> fmap (nest 2,) $ - pandocTable opts False (all null headers) aligns' widths' - rawHeaders rawRows + isEnabled Ext_simple_tables opts -> do + rawHeaders <- padRow <$> mapM (blockListToMarkdown opts) headers + rawRows <- mapM (fmap padRow . mapM (blockListToMarkdown opts)) + rows + (nest 2,) <$> pandocTable opts False (all null headers) + aligns' widths' rawHeaders rawRows | isSimple && - isEnabled Ext_pipe_tables opts -> fmap (id,) $ - pipeTable (all null headers) aligns' rawHeaders rawRows + isEnabled Ext_pipe_tables opts -> do + rawHeaders <- padRow <$> mapM (blockListToMarkdown opts) headers + rawRows <- mapM (fmap padRow . mapM (blockListToMarkdown opts)) + rows + (id,) <$> pipeTable (all null headers) aligns' rawHeaders rawRows | not hasBlocks && - isEnabled Ext_multiline_tables opts -> fmap (nest 2,) $ - pandocTable opts True (all null headers) aligns' widths' - rawHeaders rawRows + isEnabled Ext_multiline_tables opts -> do + rawHeaders <- padRow <$> mapM (blockListToMarkdown opts) headers + rawRows <- mapM (fmap padRow . mapM (blockListToMarkdown opts)) + rows + (nest 2,) <$> pandocTable opts True (all null headers) + aligns' widths' rawHeaders rawRows | isEnabled Ext_grid_tables opts && writerColumns opts >= 8 * numcols -> (id,) <$> gridTable opts blockListToMarkdown @@ -604,8 +611,11 @@ blockToMarkdown' opts t@(Table caption aligns widths headers rows) = do (text . T.unpack) <$> (writeHtml5String def $ Pandoc nullMeta [t]) | hasSimpleCells && - isEnabled Ext_pipe_tables opts -> fmap (id,) $ - pipeTable (all null headers) aligns' rawHeaders rawRows + isEnabled Ext_pipe_tables opts -> do + rawHeaders <- padRow <$> mapM (blockListToMarkdown opts) headers + rawRows <- mapM (fmap padRow . mapM (blockListToMarkdown opts)) + rows + (id,) <$> pipeTable (all null headers) aligns' rawHeaders rawRows | otherwise -> return $ (id, text "[TABLE]") return $ nst $ tbl $$ caption'' $$ blankline blockToMarkdown' opts (BulletList items) = do diff --git a/test/command/4061.md b/test/command/4061.md new file mode 100644 index 000000000..e850c5e8c --- /dev/null +++ b/test/command/4061.md @@ -0,0 +1,14 @@ +``` +% pandoc -t markdown-simple_tables-multiline_tables-pipe_tables ++-----------------------------------+ +| Text [^1] | ++-----------------------------------+ + +[^1]: Footnote. +^D ++-----------------------------------+ +| Text [^1] | ++-----------------------------------+ + +[^1]: Footnote. +``` |