aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-11-13 21:12:04 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2017-11-13 21:12:04 -0800
commit8d6e0e516a0b9d36992b2802e23dbcc6162c7346 (patch)
treea6ba003d8cc8e68443a83a5ba55b3732f3b6d9cf /src/Text/Pandoc/Writers
parent3a83b3843db6434e9806558ea1e912055d5baf04 (diff)
downloadpandoc-8d6e0e516a0b9d36992b2802e23dbcc6162c7346.tar.gz
Markdown writer: fix bug with doubled footnotes in grid tables.
Closes #4061.
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r--src/Text/Pandoc/Writers/Markdown.hs34
1 files changed, 22 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