git.iko.soy/typeable/pandoc
on master help sign in
Markdown definition lists: don't require indent for first line.

Previously the body of the definition (after the `:` or `~` marker) needed to be in column 4. This commit relaxes that requirement, to better match the behavior of PHP Markdown Extra. So, now this is a valid definition list: foo : bar This patch also helps resolve a potentially ambiguity with table captions: foo : bar ----- table ----- Is "bar" a definition, or the caption for the table? We'll count it as a caption for the table. Closes #2087.

commitd3544dc6f7a2386c4a68a85110f322b50332cfbe authorJohn MacFarlane <jgm@berkeley.edu> dateSat 18 Apr 2015, 10:13 (12 years ago) parent10e28ef
2 files changed+7−2
src/Text/Pandoc/Readers/Markdown.hs+4−2 tests/Tests/Readers/Markdown.hs+3
src/Text/Pandoc/Readers/Markdown.hs+4−2
@@ -880,7 +880,7 @@ defListMarker = do
880880 tabStop <- getOption readerTabStop
881881 let remaining = tabStop - (length sps + 1)
882882 if remaining > 0
883− then count remaining (char ' ') <|> string "\t"
883+ then try (count remaining (char ' ')) <|> string "\t" <|> many1 spaceChar
884884 else mzero
885885 return ()
886886
@@ -916,7 +916,9 @@ defRawBlock compact = try $ do
916916
917917definitionList :: MarkdownParser Blocks
918918definitionList = 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)
920922 compactDefinitionList <|> normalDefinitionList
921923
922924compactDefinitionList :: MarkdownParser Blocks
tests/Tests/Readers/Markdown.hs+3
@@ -270,6 +270,9 @@ tests = [ testGroup "inline code"
270270 definitionList [ (text "foo1", [para (text "bar") <>
271271 para (text "baz")])
272272 ]
273+ , "first line not indented" =:
274+ "foo\n: bar\n" =?>
275+ definitionList [ (text "foo", [plain (text "bar")]) ]
273276 ]
274277 , testGroup "+compact_definition_lists"
275278 [ test markdownCDL "basic compact list" $