diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Tests/Readers/RST.hs | 3 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/RST.hs | 13 |
2 files changed, 9 insertions, 7 deletions
diff --git a/src/Tests/Readers/RST.hs b/src/Tests/Readers/RST.hs index c0f60ff51..d67778f08 100644 --- a/src/Tests/Readers/RST.hs +++ b/src/Tests/Readers/RST.hs @@ -32,6 +32,8 @@ tests = [ "field list" =: with the first line, but they must be indented relative to the field name marker, and they must line up with each other. :Parameter i: integer +:Final: item + on two lines |] =?> ( setAuthors ["Me","Myself","I"] $ setDate "2001-08-16" $ doc @@ -41,6 +43,7 @@ tests = [ "field list" =: , (str "Version", [para "1"]) , (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."]) , (str "Parameter i", [para "integer"]) + , (str "Final", [para "item on two lines"]) ]) ] diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index 32fae5ee7..2cfab0f53 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -162,6 +162,7 @@ fieldListItem indent = try $ do (name, raw) <- rawFieldListItem indent let term = [Str name] contents <- parseFromString (many block) raw + optional blanklines case (name, contents) of ("Author", x) -> do updateState $ \st -> @@ -187,7 +188,6 @@ fieldList :: GenParser Char ParserState Block fieldList = try $ do indent <- lookAhead $ many spaceChar items <- many1 $ fieldListItem indent - blanklines if null items then return Null else return $ DefinitionList $ catMaybes items @@ -330,15 +330,14 @@ indentedLine indents = try $ do string indents manyTill anyChar newline --- two or more indented lines, possibly separated by blank lines. +-- one or more indented lines, possibly separated by blank lines. -- any amount of indentation will work. indentedBlock :: GenParser Char st [Char] -indentedBlock = try $ do +indentedBlock = try $ do indents <- lookAhead $ many1 spaceChar - lns <- many $ choice $ [ indentedLine indents, - try $ do b <- blanklines - l <- indentedLine indents - return (b ++ l) ] + lns <- many1 $ try $ do b <- option "" blanklines + l <- indentedLine indents + return (b ++ l) optional blanklines return $ unlines lns |