git.iko.soy/typeable/pandoc
on master help sign in
Markdown reader: handle table w/o following blank line in fenced div.
bc9d296John MacFarlane
src/Text/Pandoc/Readers/Markdown.hs+14−3
@@ -910,6 +910,17 @@ listContinuation continuationIndent = try $ do
910 blanks <- many blankline
910 blanks <- many blankline
911 return $ concat (x:xs) ++ blanks
911 return $ concat (x:xs) ++ blanks
912
912
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+
913notFollowedByDivCloser :: PandocMonad m => MarkdownParser m ()
924notFollowedByDivCloser :: PandocMonad m => MarkdownParser m ()
914notFollowedByDivCloser =
925notFollowedByDivCloser =
915 guardDisabled Ext_fenced_divs <|>
926 guardDisabled Ext_fenced_divs <|>
@@ -1251,7 +1262,7 @@ alignType strLst len =
1251
1262
1252-- Parse a table footer - dashed lines followed by blank line.
1263-- Parse a table footer - dashed lines followed by blank line.
1253tableFooter :: PandocMonad m => MarkdownParser m String
1264tableFooter :: PandocMonad m => MarkdownParser m String
1254−tableFooter = try $ skipNonindentSpaces >> many1 (dashedLine '-') >> blanklines
1265+tableFooter = try $ skipNonindentSpaces >> many1 (dashedLine '-') >> blanklines'
1255
1266
1256-- Parse a table separator - dashed line.
1267-- Parse a table separator - dashed line.
1257tableSep :: PandocMonad m => MarkdownParser m Char
1268tableSep :: PandocMonad m => MarkdownParser m Char
@@ -1262,7 +1273,7 @@ rawTableLine :: PandocMonad m
1262 => [Int]
1273 => [Int]
1263 -> MarkdownParser m [String]
1274 -> MarkdownParser m [String]
1264rawTableLine indices = do
1275rawTableLine indices = do
1265− notFollowedBy' (blanklines <|> tableFooter)
1276+ notFollowedBy' (blanklines' <|> tableFooter)
1266 line <- many1Till anyChar newline
1277 line <- many1Till anyChar newline
1267 return $ map trim $ tail $
1278 return $ map trim $ tail $
1268 splitStringByIndices (init indices) line
1279 splitStringByIndices (init indices) line
@@ -1300,7 +1311,7 @@ simpleTable headless = do
1300 (aligns, _widths, heads', lines') <-
1311 (aligns, _widths, heads', lines') <-
1301 tableWith (simpleTableHeader headless) tableLine
1312 tableWith (simpleTableHeader headless) tableLine
1302 (return ())
1313 (return ())
1303− (if headless then tableFooter else tableFooter <|> blanklines)
1314+ (if headless then tableFooter else tableFooter <|> blanklines')
1304 -- Simple tables get 0s for relative column widths (i.e., use default)
1315 -- Simple tables get 0s for relative column widths (i.e., use default)
1305 return (aligns, replicate (length aligns) 0, heads', lines')
1316 return (aligns, replicate (length aligns) 0, heads', lines')
1306
1317