diff --git a/src/Article.hs b/src/Article.hs index 0507102..bc3f066 100644 --- a/src/Article.hs +++ b/src/Article.hs @@ -5,7 +5,6 @@ module Article ( , at , getKey , preview - , titleP ) where import Control.Applicative ((<|>)) @@ -19,9 +18,8 @@ import System.Posix.Files (getFileStatus, modificationTime) import Text.ParserCombinators.Parsec ( ParseError , Parser --- , (<|>) , anyChar, char, count, endBy, eof, getPosition, many, many1, noneOf - , oneOf, option, parse, skipMany, sourceLine, spaces, string, try + , oneOf, option, parse, skipMany, sourceLine, string, try ) type Metadata = Map String String @@ -41,7 +39,7 @@ articleP = headerP = try ((,,,) <$> titleP <* many eol <*> metadataP) <|> flip (,,,) <$> metadataP <* many eol<*> titleP - lineOffset = sourceLine <$> getPosition + lineOffset = pred . sourceLine <$> getPosition bodyP = lines <$> many anyChar <* eof metadataP :: Parser Metadata @@ -52,7 +50,8 @@ metadataP = Map.fromList <$> option [] ( ) where metaSectionSeparator = count 3 (oneOf "~-") *> eol - keyVal = (,) <$> (no ": " <* spaces <* char ':' <* spaces) <*> no "\r\n" + spaces = skipMany $ char ' ' + keyVal = (,) <$> (no ": \r\n" <* spaces <* char ':' <* spaces) <*> no "\r\n" titleP :: Parser String titleP = try (singleLine <|> underlined)