git.iko.soy/typeable/pandoc
on master help sign in
Markdown reader: handle table w/o following blank line in fenced div.

Closes #4560.

commitbc9d296e5ae34f14cc03d7ca5e3b1f4295eac1d2 authorJohn MacFarlane <jgm@berkeley.edu> dateWed 18 Apr 2018, 18:27 (9 years ago) parentc5d8fab
1 file changed+14−3
src/Text/Pandoc/Readers/Markdown.hs+14−3
src/Text/Pandoc/Readers/Markdown.hs+14−3
@@ -910,6 +910,17 @@ listContinuation continuationIndent = try $ do
910910 blanks <- many blankline
911911 return $ concat (x:xs) ++ blanks
912912
913+-- Variant of blanklines that doesn't require blank lines
914+-- before a fence or eof.
915+blanklines' :: PandocMonad m => MarkdownParser m [Char]
916+blanklines' = blanklines <|> try checkDivCloser
917+ where checkDivCloser = do
918+ guardEnabled Ext_fenced_divs
919+ divLevel <- stateFencedDivLevel <$> getState
920+ guard (divLevel >= 1)
921+ lookAhead divFenceEnd
922+ return ""
923+
913924notFollowedByDivCloser :: PandocMonad m => MarkdownParser m ()
914925notFollowedByDivCloser =
915926 guardDisabled Ext_fenced_divs <|>
@@ -1251,7 +1262,7 @@ alignType strLst len =
12511262
12521263-- Parse a table footer - dashed lines followed by blank line.
12531264tableFooter :: PandocMonad m => MarkdownParser m String
1254−tableFooter = try $ skipNonindentSpaces >> many1 (dashedLine '-') >> blanklines
1265+tableFooter = try $ skipNonindentSpaces >> many1 (dashedLine '-') >> blanklines'
12551266
12561267-- Parse a table separator - dashed line.
12571268tableSep :: PandocMonad m => MarkdownParser m Char
@@ -1262,7 +1273,7 @@ rawTableLine :: PandocMonad m
12621273 => [Int]
12631274 -> MarkdownParser m [String]
12641275rawTableLine indices = do
1265− notFollowedBy' (blanklines <|> tableFooter)
1276+ notFollowedBy' (blanklines' <|> tableFooter)
12661277 line <- many1Till anyChar newline
12671278 return $ map trim $ tail $
12681279 splitStringByIndices (init indices) line
@@ -1300,7 +1311,7 @@ simpleTable headless = do
13001311 (aligns, _widths, heads', lines') <-
13011312 tableWith (simpleTableHeader headless) tableLine
13021313 (return ())
1303− (if headless then tableFooter else tableFooter <|> blanklines)
1314+ (if headless then tableFooter else tableFooter <|> blanklines')
13041315 -- Simple tables get 0s for relative column widths (i.e., use default)
13051316 return (aligns, replicate (length aligns) 0, heads', lines')
13061317