diff options
| author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2016-07-31 15:39:04 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-07-31 15:39:04 +0200 |
| commit | 9e41414880718d5f18e4ae771ef21fc9447d1b60 (patch) | |
| tree | 63659f9864780c9d50d474cb59c4d18f673c60cb /src/Hakyll/Core/Util | |
| parent | 68e9c7704216f88b73162963c06ef80616ff318a (diff) | |
| parent | a31a5654036c8d8b43d24d3d8cef4e342c517a47 (diff) | |
| download | hakyll-9e41414880718d5f18e4ae771ef21fc9447d1b60.tar.gz | |
Merge pull request #454 from samgd/whitespace-control
Whitespace trimming
Diffstat (limited to 'src/Hakyll/Core/Util')
| -rw-r--r-- | src/Hakyll/Core/Util/Parser.hs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/Hakyll/Core/Util/Parser.hs b/src/Hakyll/Core/Util/Parser.hs index e958b76..c4b2f8d 100644 --- a/src/Hakyll/Core/Util/Parser.hs +++ b/src/Hakyll/Core/Util/Parser.hs @@ -8,7 +8,7 @@ module Hakyll.Core.Util.Parser -------------------------------------------------------------------------------- import Control.Applicative ((<|>)) -import Control.Monad (mzero) +import Control.Monad (guard, mzero, void) import qualified Text.Parsec as P import Text.Parsec.String (Parser) @@ -16,7 +16,14 @@ import Text.Parsec.String (Parser) -------------------------------------------------------------------------------- metadataKey :: Parser String metadataKey = do - i <- (:) <$> P.letter <*> (P.many $ P.alphaNum <|> P.oneOf "_-.") + -- Ensure trailing '-' binds to '$' if present. + let hyphon = P.try $ do + void $ P.char '-' + x <- P.lookAhead P.anyChar + guard $ x /= '$' + pure '-' + + i <- (:) <$> P.letter <*> P.many (P.alphaNum <|> P.oneOf "_." <|> hyphon) if i `elem` reservedKeys then mzero else return i |
