git.iko.soy/typeable/pandoc
on master help sign in
Fixed bug in RST field list parser.
403bb52John MacFarlane
src/Tests/Readers/RST.hs+3
@@ -32,6 +32,8 @@ tests = [ "field list" =:
32 with the first line, but they must be indented relative to the
32 with the first line, but they must be indented relative to the
33 field name marker, and they must line up with each other.
33 field name marker, and they must line up with each other.
34:Parameter i: integer
34:Parameter i: integer
35+:Final: item
36+ on two lines
35|] =?> ( setAuthors ["Me","Myself","I"]
37|] =?> ( setAuthors ["Me","Myself","I"]
36 $ setDate "2001-08-16"
38 $ setDate "2001-08-16"
37 $ doc
39 $ doc
@@ -41,6 +43,7 @@ tests = [ "field list" =:
41 , (str "Version", [para "1"])
43 , (str "Version", [para "1"])
42 , (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."])
44 , (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."])
43 , (str "Parameter i", [para "integer"])
45 , (str "Parameter i", [para "integer"])
46+ , (str "Final", [para "item on two lines"])
44 ])
47 ])
45 ]
48 ]
46
49
src/Text/Pandoc/Readers/RST.hs+6−7
@@ -162,6 +162,7 @@ fieldListItem indent = try $ do
162 (name, raw) <- rawFieldListItem indent
162 (name, raw) <- rawFieldListItem indent
163 let term = [Str name]
163 let term = [Str name]
164 contents <- parseFromString (many block) raw
164 contents <- parseFromString (many block) raw
165+ optional blanklines
165 case (name, contents) of
166 case (name, contents) of
166 ("Author", x) -> do
167 ("Author", x) -> do
167 updateState $ \st ->
168 updateState $ \st ->
@@ -187,7 +188,6 @@ fieldList :: GenParser Char ParserState Block
187fieldList = try $ do
188fieldList = try $ do
188 indent <- lookAhead $ many spaceChar
189 indent <- lookAhead $ many spaceChar
189 items <- many1 $ fieldListItem indent
190 items <- many1 $ fieldListItem indent
190− blanklines
191 if null items
191 if null items
192 then return Null
192 then return Null
193 else return $ DefinitionList $ catMaybes items
193 else return $ DefinitionList $ catMaybes items
@@ -330,15 +330,14 @@ indentedLine indents = try $ do
330 string indents
330 string indents
331 manyTill anyChar newline
331 manyTill anyChar newline
332
332
333−-- two or more indented lines, possibly separated by blank lines.
333+-- one or more indented lines, possibly separated by blank lines.
334-- any amount of indentation will work.
334-- any amount of indentation will work.
335indentedBlock :: GenParser Char st [Char]
335indentedBlock :: GenParser Char st [Char]
336−indentedBlock = try $ do
336+indentedBlock = try $ do
337 indents <- lookAhead $ many1 spaceChar
337 indents <- lookAhead $ many1 spaceChar
338− lns <- many $ choice $ [ indentedLine indents,
339− try $ do b <- blanklines
338+ lns <- many1 $ try $ do b <- option "" blanklines
340− l <- indentedLine indents
339+ l <- indentedLine indents
341− return (b ++ l) ]
340+ return (b ++ l)
342 optional blanklines
341 optional blanklines
343 return $ unlines lns
342 return $ unlines lns
344
343