diff options
author | Jasper Van der Jeugt <m@jaspervdj.be> | 2012-11-10 18:11:46 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <m@jaspervdj.be> | 2012-11-10 18:11:46 +0100 |
commit | 141e761ce11d4d4ae9e9b86201249dbd549e2924 (patch) | |
tree | 0d0ba398331bceb9326c58392680fb81361fb6c3 /src/Hakyll/Core/ResourceProvider | |
parent | 260e4e2e8936f756d2f3a2e6e788f05ca28e4324 (diff) | |
download | hakyll-141e761ce11d4d4ae9e9b86201249dbd549e2924.tar.gz |
Deprecate things, basics now work
Diffstat (limited to 'src/Hakyll/Core/ResourceProvider')
-rw-r--r-- | src/Hakyll/Core/ResourceProvider/Metadata.hs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/Hakyll/Core/ResourceProvider/Metadata.hs b/src/Hakyll/Core/ResourceProvider/Metadata.hs index e297f2c..2b0615c 100644 --- a/src/Hakyll/Core/ResourceProvider/Metadata.hs +++ b/src/Hakyll/Core/ResourceProvider/Metadata.hs @@ -6,7 +6,7 @@ module Hakyll.Core.ResourceProvider.Metadata -------------------------------------------------------------------------------- -import Control.Applicative ((<$>), (<*), (<*>)) +import Control.Applicative import Control.Arrow (second) import qualified Data.ByteString.Char8 as BC import qualified Data.Map as M @@ -80,16 +80,22 @@ inlineSpace = P.oneOf ['\t', ' '] <?> "space" -------------------------------------------------------------------------------- +-- | Parse Windows newlines as well (i.e. "\n" or "\r\n") +newline :: Parser String +newline = P.string "\n" <|> P.string "\r\n" + + +-------------------------------------------------------------------------------- -- | Parse a single metadata field metadataField :: Parser (String, String) metadataField = do key <- P.manyTill P.alphaNum $ P.char ':' P.skipMany1 inlineSpace <?> "space followed by metadata for: " ++ key - value <- P.manyTill P.anyChar P.newline + value <- P.manyTill P.anyChar newline trailing' <- P.many trailing return (key, trim $ value ++ concat trailing') where - trailing = (++) <$> P.many1 inlineSpace <*> P.manyTill P.anyChar P.newline + trailing = (++) <$> P.many1 inlineSpace <*> P.manyTill P.anyChar newline -------------------------------------------------------------------------------- @@ -102,11 +108,11 @@ metadata = P.many metadataField -- | Parse a metadata block, including delimiters and trailing newlines metadataBlock :: Parser [(String, String)] metadataBlock = do - open <- P.many1 (P.char '-') <* P.many inlineSpace <* P.newline + open <- P.many1 (P.char '-') <* P.many inlineSpace <* newline metadata' <- metadata _ <- P.choice $ map (P.string . replicate (length open)) ['-', '.'] P.skipMany inlineSpace - P.skipMany1 P.newline + P.skipMany1 newline return metadata' |