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.
This commit is contained in:
parent
10e28ef750
commit
d3544dc6f7
2 changed files with 7 additions and 2 deletions
|
@ -880,7 +880,7 @@ defListMarker = do
|
||||||
tabStop <- getOption readerTabStop
|
tabStop <- getOption readerTabStop
|
||||||
let remaining = tabStop - (length sps + 1)
|
let remaining = tabStop - (length sps + 1)
|
||||||
if remaining > 0
|
if remaining > 0
|
||||||
then count remaining (char ' ') <|> string "\t"
|
then try (count remaining (char ' ')) <|> string "\t" <|> many1 spaceChar
|
||||||
else mzero
|
else mzero
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
|
@ -916,7 +916,9 @@ defRawBlock compact = try $ do
|
||||||
|
|
||||||
definitionList :: MarkdownParser Blocks
|
definitionList :: MarkdownParser Blocks
|
||||||
definitionList = try $ do
|
definitionList = try $ do
|
||||||
lookAhead (anyLine >> optional blankline >> defListMarker)
|
lookAhead (anyLine >> optional (blankline >> notFollowedBy table) >>
|
||||||
|
-- don't capture table caption as def list!
|
||||||
|
defListMarker)
|
||||||
compactDefinitionList <|> normalDefinitionList
|
compactDefinitionList <|> normalDefinitionList
|
||||||
|
|
||||||
compactDefinitionList :: MarkdownParser Blocks
|
compactDefinitionList :: MarkdownParser Blocks
|
||||||
|
|
|
@ -270,6 +270,9 @@ tests = [ testGroup "inline code"
|
||||||
definitionList [ (text "foo1", [para (text "bar") <>
|
definitionList [ (text "foo1", [para (text "bar") <>
|
||||||
para (text "baz")])
|
para (text "baz")])
|
||||||
]
|
]
|
||||||
|
, "first line not indented" =:
|
||||||
|
"foo\n: bar\n" =?>
|
||||||
|
definitionList [ (text "foo", [plain (text "bar")]) ]
|
||||||
]
|
]
|
||||||
, testGroup "+compact_definition_lists"
|
, testGroup "+compact_definition_lists"
|
||||||
[ test markdownCDL "basic compact list" $
|
[ test markdownCDL "basic compact list" $
|
||||||
|
|
Loading…
Reference in a new issue