diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-01-19 15:50:04 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-01-19 15:50:04 +0100 |
commit | fe77089955dbf1002496e34824da13bfaf64a898 (patch) | |
tree | 8df1a154b5ae23e9e12045490ba49546dbf98b18 | |
parent | f5a6c4974d561e05b2882d38b54b45188ee31185 (diff) | |
download | hakyll-fe77089955dbf1002496e34824da13bfaf64a898.tar.gz |
Made page parser a little less strict.
-rw-r--r-- | src/Text/Hakyll/Page.hs | 7 | ||||
-rw-r--r-- | src/Text/Hakyll/Render/Internal.hs | 4 |
2 files changed, 6 insertions, 5 deletions
diff --git a/src/Text/Hakyll/Page.hs b/src/Text/Hakyll/Page.hs index 9c01801..d120443 100644 --- a/src/Text/Hakyll/Page.hs +++ b/src/Text/Hakyll/Page.hs @@ -8,6 +8,7 @@ module Text.Hakyll.Page import qualified Data.Map as M import qualified Data.List as L +import Data.Char (isSpace) import Data.Maybe (fromMaybe) import Control.Parallel.Strategies (rdeepseq, ($|)) import Control.Monad.Reader (liftIO) @@ -121,16 +122,16 @@ readSection renderFunction isFirst ls | otherwise = body (tail ls) where isDelimiter' = isDelimiter (head ls) - isNamedDelimiter = head ls `matchesRegex` "----* *[a-zA-Z][a-zA-Z]*" + isNamedDelimiter = head ls `matchesRegex` "----* *[a-zA-Z0-9][a-zA-Z0-9]*" body ls' = [("body", renderFunction $ unlines ls')] - readSimpleMetaData = map readPair + readSimpleMetaData = map readPair . filter (not . all isSpace) readPair = trimPair . break (== ':') trimPair (key, value) = (trim key, trim $ tail value) readSectionMetaData [] = [] readSectionMetaData (header:value) = - let key = substituteRegex "[^a-zA-Z]" "" header + let key = substituteRegex "[^a-zA-Z0-9]" "" header in [(key, renderFunction $ unlines value)] -- | Read a page from a file. Metadata is supported, and if the filename diff --git a/src/Text/Hakyll/Render/Internal.hs b/src/Text/Hakyll/Render/Internal.hs index 89a2709..d0b5814 100644 --- a/src/Text/Hakyll/Render/Internal.hs +++ b/src/Text/Hakyll/Render/Internal.hs @@ -13,7 +13,7 @@ import qualified Data.Map as M import Text.Hakyll.Context (Context, ContextManipulation) import Control.Monad.Reader (liftIO) import Data.List (isPrefixOf, foldl') -import Data.Char (isAlpha) +import Data.Char (isAlphaNum) import Data.Maybe (fromMaybe) import Control.Parallel.Strategies (rdeepseq, ($|)) @@ -33,7 +33,7 @@ substitute escaper string context | otherwise = head string : substitute' tail' where tail' = tail string - (key, rest) = span isAlpha tail' + (key, rest) = span isAlphaNum tail' replacement = fromMaybe ('$' : key) $ M.lookup key context substituteKey = replacement ++ substitute' rest substitute' str = substitute escaper str context |