git.iko.soy/typeable/pandoc
on master help sign in
Markdown writer: fix bug with doubled footnotes in grid tables.
8d6e0e5John MacFarlane
src/Text/Pandoc/Writers/Markdown.hs+22−12
@@ -575,8 +575,6 @@ blockToMarkdown' opts t@(Table caption aligns widths headers rows) = do
575 let padRow r = case numcols - length r of
575 let padRow r = case numcols - length r of
576 x | x > 0 -> r ++ replicate x empty
576 x | x > 0 -> r ++ replicate x empty
577 | otherwise -> r
577 | otherwise -> r
578− rawHeaders <- padRow <$> mapM (blockListToMarkdown opts) headers
579− rawRows <- mapM (fmap padRow . mapM (blockListToMarkdown opts)) rows
580 let aligns' = case numcols - length aligns of
578 let aligns' = case numcols - length aligns of
581 x | x > 0 -> aligns ++ replicate x AlignDefault
579 x | x > 0 -> aligns ++ replicate x AlignDefault
582 | otherwise -> aligns
580 | otherwise -> aligns
@@ -586,16 +584,25 @@ blockToMarkdown' opts t@(Table caption aligns widths headers rows) = do
586 (nst,tbl) <-
584 (nst,tbl) <-
587 case True of
585 case True of
588 _ | isSimple &&
586 _ | isSimple &&
589− isEnabled Ext_simple_tables opts -> fmap (nest 2,) $
587+ isEnabled Ext_simple_tables opts -> do
588+ rawHeaders <- padRow <$> mapM (blockListToMarkdown opts) headers
589+ rawRows <- mapM (fmap padRow . mapM (blockListToMarkdown opts))
590+ rows
590− pandocTable opts False (all null headers) aligns' widths'
591+ (nest 2,) <$> pandocTable opts False (all null headers)
591− rawHeaders rawRows
592+ aligns' widths' rawHeaders rawRows
592 | isSimple &&
593 | isSimple &&
593− isEnabled Ext_pipe_tables opts -> fmap (id,) $
594+ isEnabled Ext_pipe_tables opts -> do
595+ rawHeaders <- padRow <$> mapM (blockListToMarkdown opts) headers
596+ rawRows <- mapM (fmap padRow . mapM (blockListToMarkdown opts))
597+ rows
594− pipeTable (all null headers) aligns' rawHeaders rawRows
598+ (id,) <$> pipeTable (all null headers) aligns' rawHeaders rawRows
595 | not hasBlocks &&
599 | not hasBlocks &&
596− isEnabled Ext_multiline_tables opts -> fmap (nest 2,) $
600+ isEnabled Ext_multiline_tables opts -> do
601+ rawHeaders <- padRow <$> mapM (blockListToMarkdown opts) headers
602+ rawRows <- mapM (fmap padRow . mapM (blockListToMarkdown opts))
603+ rows
597− pandocTable opts True (all null headers) aligns' widths'
604+ (nest 2,) <$> pandocTable opts True (all null headers)
598− rawHeaders rawRows
605+ aligns' widths' rawHeaders rawRows
599 | isEnabled Ext_grid_tables opts &&
606 | isEnabled Ext_grid_tables opts &&
600 writerColumns opts >= 8 * numcols -> (id,) <$>
607 writerColumns opts >= 8 * numcols -> (id,) <$>
601 gridTable opts blockListToMarkdown
608 gridTable opts blockListToMarkdown
@@ -604,8 +611,11 @@ blockToMarkdown' opts t@(Table caption aligns widths headers rows) = do
604 (text . T.unpack) <$>
611 (text . T.unpack) <$>
605 (writeHtml5String def $ Pandoc nullMeta [t])
612 (writeHtml5String def $ Pandoc nullMeta [t])
606 | hasSimpleCells &&
613 | hasSimpleCells &&
607− isEnabled Ext_pipe_tables opts -> fmap (id,) $
614+ isEnabled Ext_pipe_tables opts -> do
615+ rawHeaders <- padRow <$> mapM (blockListToMarkdown opts) headers
616+ rawRows <- mapM (fmap padRow . mapM (blockListToMarkdown opts))
617+ rows
608− pipeTable (all null headers) aligns' rawHeaders rawRows
618+ (id,) <$> pipeTable (all null headers) aligns' rawHeaders rawRows
609 | otherwise -> return $ (id, text "[TABLE]")
619 | otherwise -> return $ (id, text "[TABLE]")
610 return $ nst $ tbl $$ caption'' $$ blankline
620 return $ nst $ tbl $$ caption'' $$ blankline
611blockToMarkdown' opts (BulletList items) = do
621blockToMarkdown' opts (BulletList items) = do
test/command/4061.mdnew file+14
@@ -0,0 +1,14 @@
1+```
2+% pandoc -t markdown-simple_tables-multiline_tables-pipe_tables
3++-----------------------------------+
4+| Text [^1] |
5++-----------------------------------+
6+
7+[^1]: Footnote.
8+^D
9++-----------------------------------+
10+| Text [^1] |
11++-----------------------------------+
12+
13+[^1]: Footnote.
14+```