git.iko.soy/typeable/pandoc
on master help sign in
Markdown definition lists: don't require indent for first line.
d3544dcJohn MacFarlane
src/Text/Pandoc/Readers/Markdown.hs+4−2
@@ -880,7 +880,7 @@ defListMarker = do
880 tabStop <- getOption readerTabStop
880 tabStop <- getOption readerTabStop
881 let remaining = tabStop - (length sps + 1)
881 let remaining = tabStop - (length sps + 1)
882 if remaining > 0
882 if remaining > 0
883− then count remaining (char ' ') <|> string "\t"
883+ then try (count remaining (char ' ')) <|> string "\t" <|> many1 spaceChar
884 else mzero
884 else mzero
885 return ()
885 return ()
886
886
@@ -916,7 +916,9 @@ defRawBlock compact = try $ do
916
916
917definitionList :: MarkdownParser Blocks
917definitionList :: MarkdownParser Blocks
918definitionList = try $ do
918definitionList = try $ do
919− lookAhead (anyLine >> optional blankline >> defListMarker)
919+ lookAhead (anyLine >> optional (blankline >> notFollowedBy table) >>
920+ -- don't capture table caption as def list!
921+ defListMarker)
920 compactDefinitionList <|> normalDefinitionList
922 compactDefinitionList <|> normalDefinitionList
921
923
922compactDefinitionList :: MarkdownParser Blocks
924compactDefinitionList :: MarkdownParser Blocks
tests/Tests/Readers/Markdown.hs+3
@@ -270,6 +270,9 @@ tests = [ testGroup "inline code"
270 definitionList [ (text "foo1", [para (text "bar") <>
270 definitionList [ (text "foo1", [para (text "bar") <>
271 para (text "baz")])
271 para (text "baz")])
272 ]
272 ]
273+ , "first line not indented" =:
274+ "foo\n: bar\n" =?>
275+ definitionList [ (text "foo", [plain (text "bar")]) ]
273 ]
276 ]
274 , testGroup "+compact_definition_lists"
277 , testGroup "+compact_definition_lists"
275 [ test markdownCDL "basic compact list" $
278 [ test markdownCDL "basic compact list" $