From 72d11ad20bd5f291c373b1aeb09cc869905b0f26 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 27 Jan 2013 22:13:05 -0800 Subject: [PATCH] Markdown/RST reader: Skip blank lines. This fixes a subtle regression involving grid tables with empty cells. Closes #732. Also added test for grid table with empty cells. --- src/Text/Pandoc/Readers/Markdown.hs | 3 ++- src/Text/Pandoc/Readers/RST.hs | 1 + tests/markdown-reader-more.native | 8 +++++++- tests/markdown-reader-more.txt | 15 +++++++++++---- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 44cbbc676..9113cb75e 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -373,6 +373,7 @@ block = choice [ codeBlockFenced , abbrevKey , para , plain + , mempty <$ blanklines ] "block" -- @@ -807,7 +808,7 @@ para = try $ do _ -> return $ B.para result' plain :: MarkdownParser (F Blocks) -plain = fmap B.plain . trimInlinesF . mconcat <$> many1 inline <* spaces +plain = fmap B.plain . trimInlinesF . mconcat <$> many1 inline -- -- raw html diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index c5e2617da..378e49703 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -143,6 +143,7 @@ block = choice [ codeBlock , list , lhsCodeBlock , para + , mempty <$ blanklines ] "block" -- diff --git a/tests/markdown-reader-more.native b/tests/markdown-reader-more.native index 382aa056c..69b29992c 100644 --- a/tests/markdown-reader-more.native +++ b/tests/markdown-reader-more.native @@ -118,4 +118,10 @@ [[Plain [Str "b"]] ,[Plain [Str "b",Space,Str "2"]] ,[Plain [Str "b",Space,Str "2"]]]] - ,[Para [Str "c",Space,Str "c",Space,Str "2",Space,Str "c",Space,Str "2"]]]]] + ,[Para [Str "c",Space,Str "c",Space,Str "2",Space,Str "c",Space,Str "2"]]]] +,Para [Str "Empty",Space,Str "cells"] +,Table [] [AlignDefault,AlignDefault] [5.555555555555555e-2,5.555555555555555e-2] + [[] + ,[]] + [[[] + ,[]]]] diff --git a/tests/markdown-reader-more.txt b/tests/markdown-reader-more.txt index b76b6d985..e471100d2 100644 --- a/tests/markdown-reader-more.txt +++ b/tests/markdown-reader-more.txt @@ -196,8 +196,15 @@ Multiple blocks in a cell +------------------+-----------+------------+ | # col 1 | # col 2 | # col 3 | | col 1 | col 2 | col 3 | -+------------------+-----------+------------+ -| r1 a | - b | c | -| | - b 2 | c 2 | -| r1 bis | - b 2 | c 2 | +------------------+-----------+------------+ +| r1 a | - b | c | +| | - b 2 | c 2 | +| r1 bis | - b 2 | c 2 | ++------------------+-----------+------------+ + +Empty cells + ++---+---+ +| | | ++---+---+ +