diff options
author | John MacFarlane <jgm@berkeley.edu> | 2014-08-08 12:16:44 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-08-08 12:18:47 -0700 |
commit | 7b47042ae6b44674f714c4ef660dadd7c911112b (patch) | |
tree | b19fe7b58cc69b2a2d4bf87fd4c84702c8b845a6 | |
parent | dd78dd6d1beb860416c1c9114064d2e7bc1ff86a (diff) | |
download | pandoc-7b47042ae6b44674f714c4ef660dadd7c911112b.tar.gz |
Textile reader: fixed list parsing bug. Closes #1500.
-rw-r--r-- | src/Text/Pandoc/Readers/Textile.hs | 21 | ||||
-rw-r--r-- | tests/textile-reader.native | 4 | ||||
-rw-r--r-- | tests/textile-reader.textile | 6 |
3 files changed, 26 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Readers/Textile.hs b/src/Text/Pandoc/Readers/Textile.hs index 0562bd2ce..cd34da942 100644 --- a/src/Text/Pandoc/Readers/Textile.hs +++ b/src/Text/Pandoc/Readers/Textile.hs @@ -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 diff --git a/tests/textile-reader.native b/tests/textile-reader.native index a17bd8de1..f82c4a896 100644 --- a/tests/textile-reader.native +++ b/tests/textile-reader.native @@ -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"], diff --git a/tests/textile-reader.textile b/tests/textile-reader.textile index 73c36b0d1..c0c0659b7 100644 --- a/tests/textile-reader.textile +++ b/tests/textile-reader.textile @@ -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 |