Textile reader: fixed list parsing bug. Closes #1500.

This commit is contained in:
John MacFarlane 2014-08-08 12:16:44 -07:00
parent dd78dd6d1b
commit 7b47042ae6
3 changed files with 26 additions and 5 deletions

View file

@ -265,8 +265,20 @@ definitionList :: Parser [Char] ParserState Blocks
definitionList = try $ B.definitionList <$> many1 definitionListItem
-- | List start character.
listStart :: Parser [Char] st Char
listStart = oneOf "*#-"
listStart :: Parser [Char] ParserState ()
listStart = genericListStart '*'
<|> () <$ genericListStart '#'
<|> () <$ definitionListStart
genericListStart :: Char -> Parser [Char] st ()
genericListStart c = () <$ try (many1 (char c) >> whitespace)
definitionListStart :: Parser [Char] ParserState Inlines
definitionListStart = try $ do
char '-'
whitespace
trimInlines . mconcat <$>
many1Till inline (try (string ":=")) <* optional whitespace
listInline :: Parser [Char] ParserState Inlines
listInline = try (notFollowedBy newline >> inline)
@ -278,8 +290,7 @@ listInline = try (notFollowedBy newline >> inline)
-- break.
definitionListItem :: Parser [Char] ParserState (Inlines, [Blocks])
definitionListItem = try $ do
string "- "
term <- mconcat <$> many1Till inline (try (whitespace >> string ":="))
term <- definitionListStart
def' <- multilineDef <|> inlineDef
return (term, def')
where inlineDef :: Parser [Char] ParserState [Blocks]
@ -488,7 +499,7 @@ str = do
return $ B.str fullStr
-- | Some number of space chars
whitespace :: Parser [Char] ParserState Inlines
whitespace :: Parser [Char] st Inlines
whitespace = many1 spaceChar >> return B.space <?> "whitespace"
-- | In Textile, an isolated endline character is a line break

View file

@ -63,6 +63,10 @@ Pandoc (Meta {unMeta = fromList []})
,BulletList
[[Plain [Str "ui",Space,Str "2.1.1"]]
,[Plain [Str "ui",Space,Str "2.1.2"]]]]]]]
,Header 2 ("issue-1500",[],[]) [Str "Issue",Space,Str "#1500"]
,BulletList
[[Plain [Str "one"]]
,[Plain [Str "two",LineBreak,Str "->",Space,Str "and",Space,Str "more"]]]
,Header 2 ("definition-list",[],[]) [Str "Definition",Space,Str "List"]
,DefinitionList
[([Str "coffee"],

View file

@ -117,6 +117,12 @@ h2. Nested
*** ui 2.1.1
*** ui 2.1.2
h2. Issue #1500
* one
* two
-> and more
h2. Definition List
- coffee := Hot and black