summaryrefslogtreecommitdiff
path: root/src/Hakyll/Core
diff options
context:
space:
mode:
authorsamgd <sam@samgd.com>2016-07-23 14:46:15 +0200
committersamgd <sam@samgd.com>2016-07-23 14:46:15 +0200
commit9867094bd27ed170315e7e02b788243d654c6bc1 (patch)
tree04911e756c9c5e8bfaeff241c091d63bb95c5f0b /src/Hakyll/Core
parent430a0a8849191edfa7b53dcf76a0fb72f12ebde7 (diff)
downloadhakyll-9867094bd27ed170315e7e02b788243d654c6bc1.tar.gz
Expr trimming. '-' binds to '$'.
Diffstat (limited to 'src/Hakyll/Core')
-rw-r--r--src/Hakyll/Core/Util/Parser.hs11
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