git.iko.soy/typeable/pandoc
on master help sign in
Fixed bug in RST field list parser.

The bug affected field lists with multi-line items at the end of the list.

commit403bb521cd78942096ae70f9c37f18da58d6290d authorJohn MacFarlane <jgm@berkeley.edu> dateSat 12 Mar 2011, 17:08 (16 years ago) parente24ce1c
2 files changed+9−7
src/Tests/Readers/RST.hs+3 src/Text/Pandoc/Readers/RST.hs+6−7
src/Tests/Readers/RST.hs+3
@@ -32,6 +32,8 @@ tests = [ "field list" =:
3232 with the first line, but they must be indented relative to the
3333 field name marker, and they must line up with each other.
3434:Parameter i: integer
35+:Final: item
36+ on two lines
3537|] =?> ( setAuthors ["Me","Myself","I"]
3638 $ setDate "2001-08-16"
3739 $ doc
@@ -41,6 +43,7 @@ tests = [ "field list" =:
4143 , (str "Version", [para "1"])
4244 , (str "Indentation", [para "Since the field marker may be quite long, the second and subsequent lines of the field body do not have to line up with the first line, but they must be indented relative to the field name marker, and they must line up with each other."])
4345 , (str "Parameter i", [para "integer"])
46+ , (str "Final", [para "item on two lines"])
4447 ])
4548 ]
4649
src/Text/Pandoc/Readers/RST.hs+6−7
@@ -162,6 +162,7 @@ fieldListItem indent = try $ do
162162 (name, raw) <- rawFieldListItem indent
163163 let term = [Str name]
164164 contents <- parseFromString (many block) raw
165+ optional blanklines
165166 case (name, contents) of
166167 ("Author", x) -> do
167168 updateState $ \st ->
@@ -187,7 +188,6 @@ fieldList :: GenParser Char ParserState Block
187188fieldList = try $ do
188189 indent <- lookAhead $ many spaceChar
189190 items <- many1 $ fieldListItem indent
190− blanklines
191191 if null items
192192 then return Null
193193 else return $ DefinitionList $ catMaybes items
@@ -330,15 +330,14 @@ indentedLine indents = try $ do
330330 string indents
331331 manyTill anyChar newline
332332
333−-- two or more indented lines, possibly separated by blank lines.
333+-- one or more indented lines, possibly separated by blank lines.
334334-- any amount of indentation will work.
335335indentedBlock :: GenParser Char st [Char]
336−indentedBlock = try $ do
336+indentedBlock = try $ do
337337 indents <- lookAhead $ many1 spaceChar
338− lns <- many $ choice $ [ indentedLine indents,
339− try $ do b <- blanklines
340− l <- indentedLine indents
341− return (b ++ l) ]
338+ lns <- many1 $ try $ do b <- option "" blanklines
339+ l <- indentedLine indents
340+ return (b ++ l)
342341 optional blanklines
343342 return $ unlines lns
344343