RST reader: Small tweaks to raw field lists.

* Don't allow line breaks in field names.
* Strip off initial newline from 'raw' when field body
  begins on next line.
This commit is contained in:
John MacFarlane 2012-09-16 10:29:35 -07:00
parent 9f89269941
commit ecc206f7c3

View file

@ -151,13 +151,12 @@ rawFieldListItem :: String -> Parser [Char] ParserState (String, String)
rawFieldListItem indent = try $ do
string indent
char ':'
name <- many1 $ noneOf ":"
char ':'
name <- many1Till (noneOf "\n") (char ':')
skipSpaces
first <- manyTill anyChar newline
rest <- option "" $ try $ do lookAhead (string indent >> spaceChar)
indentedBlock
let raw = first ++ "\n" ++ rest ++ "\n"
let raw = (if null first then "" else (first ++ "\n")) ++ rest ++ "\n"
return (name, raw)
fieldListItem :: String