aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-04-18 18:27:15 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2018-04-18 18:27:15 -0700
commitbc9d296e5ae34f14cc03d7ca5e3b1f4295eac1d2 (patch)
treee05a9ccdb0a963c1878c225dc0d7d6d6fbf9142d /src/Text
parentc5d8fab058ee5a9b069b17399a1ef93ce3ca8e0e (diff)
downloadpandoc-bc9d296e5ae34f14cc03d7ca5e3b1f4295eac1d2.tar.gz
Markdown reader: handle table w/o following blank line in fenced div.
Closes #4560.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index fb42612ca..3a1346fdc 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -910,6 +910,17 @@ listContinuation continuationIndent = try $ do
blanks <- many blankline
return $ concat (x:xs) ++ blanks
+-- Variant of blanklines that doesn't require blank lines
+-- before a fence or eof.
+blanklines' :: PandocMonad m => MarkdownParser m [Char]
+blanklines' = blanklines <|> try checkDivCloser
+ where checkDivCloser = do
+ guardEnabled Ext_fenced_divs
+ divLevel <- stateFencedDivLevel <$> getState
+ guard (divLevel >= 1)
+ lookAhead divFenceEnd
+ return ""
+
notFollowedByDivCloser :: PandocMonad m => MarkdownParser m ()
notFollowedByDivCloser =
guardDisabled Ext_fenced_divs <|>
@@ -1251,7 +1262,7 @@ alignType strLst len =
-- Parse a table footer - dashed lines followed by blank line.
tableFooter :: PandocMonad m => MarkdownParser m String
-tableFooter = try $ skipNonindentSpaces >> many1 (dashedLine '-') >> blanklines
+tableFooter = try $ skipNonindentSpaces >> many1 (dashedLine '-') >> blanklines'
-- Parse a table separator - dashed line.
tableSep :: PandocMonad m => MarkdownParser m Char
@@ -1262,7 +1273,7 @@ rawTableLine :: PandocMonad m
=> [Int]
-> MarkdownParser m [String]
rawTableLine indices = do
- notFollowedBy' (blanklines <|> tableFooter)
+ notFollowedBy' (blanklines' <|> tableFooter)
line <- many1Till anyChar newline
return $ map trim $ tail $
splitStringByIndices (init indices) line
@@ -1300,7 +1311,7 @@ simpleTable headless = do
(aligns, _widths, heads', lines') <-
tableWith (simpleTableHeader headless) tableLine
(return ())
- (if headless then tableFooter else tableFooter <|> blanklines)
+ (if headless then tableFooter else tableFooter <|> blanklines')
-- Simple tables get 0s for relative column widths (i.e., use default)
return (aligns, replicate (length aligns) 0, heads', lines')