git.iko.soy/typeable/pandoc
on master help sign in
Textile reader: fixed list parsing bug. Closes #1500.
commit7b47042ae6b44674f714c4ef660dadd7c911112b authorJohn MacFarlane <jgm@berkeley.edu> dateFri 8 Aug 2014, 12:16 (12 years ago) parentdd78dd6
3 files changed+26−5
src/Text/Pandoc/Readers/Textile.hs+16−5 tests/textile-reader.native+4 tests/textile-reader.textile+6
src/Text/Pandoc/Readers/Textile.hs+16−5
@@ -265,8 +265,20 @@ definitionList :: Parser [Char] ParserState Blocks
265265definitionList = try $ B.definitionList <$> many1 definitionListItem
266266
267267-- | List start character.
268−listStart :: Parser [Char] st Char
269−listStart = oneOf "*#-"
268+listStart :: Parser [Char] ParserState ()
269+listStart = genericListStart '*'
270+ <|> () <$ genericListStart '#'
271+ <|> () <$ definitionListStart
272+
273+genericListStart :: Char -> Parser [Char] st ()
274+genericListStart c = () <$ try (many1 (char c) >> whitespace)
275+
276+definitionListStart :: Parser [Char] ParserState Inlines
277+definitionListStart = try $ do
278+ char '-'
279+ whitespace
280+ trimInlines . mconcat <$>
281+ many1Till inline (try (string ":=")) <* optional whitespace
270282
271283listInline :: Parser [Char] ParserState Inlines
272284listInline = try (notFollowedBy newline >> inline)
@@ -278,8 +290,7 @@ listInline = try (notFollowedBy newline >> inline)
278290-- break.
279291definitionListItem :: Parser [Char] ParserState (Inlines, [Blocks])
280292definitionListItem = try $ do
281− string "- "
282− term <- mconcat <$> many1Till inline (try (whitespace >> string ":="))
293+ term <- definitionListStart
283294 def' <- multilineDef <|> inlineDef
284295 return (term, def')
285296 where inlineDef :: Parser [Char] ParserState [Blocks]
@@ -488,7 +499,7 @@ str = do
488499 return $ B.str fullStr
489500
490501-- | Some number of space chars
491−whitespace :: Parser [Char] ParserState Inlines
502+whitespace :: Parser [Char] st Inlines
492503whitespace = many1 spaceChar >> return B.space <?> "whitespace"
493504
494505-- | In Textile, an isolated endline character is a line break
tests/textile-reader.native+4
@@ -63,6 +63,10 @@ Pandoc (Meta {unMeta = fromList []})
6363 ,BulletList
6464 [[Plain [Str "ui",Space,Str "2.1.1"]]
6565 ,[Plain [Str "ui",Space,Str "2.1.2"]]]]]]]
66+,Header 2 ("issue-1500",[],[]) [Str "Issue",Space,Str "#1500"]
67+,BulletList
68+ [[Plain [Str "one"]]
69+ ,[Plain [Str "two",LineBreak,Str "->",Space,Str "and",Space,Str "more"]]]
6670,Header 2 ("definition-list",[],[]) [Str "Definition",Space,Str "List"]
6771,DefinitionList
6872 [([Str "coffee"],
tests/textile-reader.textile+6
@@ -117,6 +117,12 @@ h2. Nested
117117*** ui 2.1.1
118118*** ui 2.1.2
119119
120+h2. Issue #1500
121+
122+* one
123+* two
124+-> and more
125+
120126h2. Definition List
121127
122128- coffee := Hot and black