on master help sign in
Made page parser a little less strict.
fe77089Jasper Van der Jeugt
src/Text/Hakyll/Page.hs+4−3
@@ -8,6 +8,7 @@ module Text.Hakyll.Page
8
8
9import qualified Data.Map as M
9import qualified Data.Map as M
10import qualified Data.List as L
10import qualified Data.List as L
11+import Data.Char (isSpace)
11import Data.Maybe (fromMaybe)
12import Data.Maybe (fromMaybe)
12import Control.Parallel.Strategies (rdeepseq, ($|))
13import Control.Parallel.Strategies (rdeepseq, ($|))
13import Control.Monad.Reader (liftIO)
14import Control.Monad.Reader (liftIO)
@@ -121,16 +122,16 @@ readSection renderFunction isFirst ls
121 | otherwise = body (tail ls)
122 | otherwise = body (tail ls)
122 where
123 where
123 isDelimiter' = isDelimiter (head ls)
124 isDelimiter' = isDelimiter (head ls)
124− isNamedDelimiter = head ls `matchesRegex` "----* *[a-zA-Z][a-zA-Z]*"
125+ isNamedDelimiter = head ls `matchesRegex` "----* *[a-zA-Z0-9][a-zA-Z0-9]*"
125 body ls' = [("body", renderFunction $ unlines ls')]
126 body ls' = [("body", renderFunction $ unlines ls')]
126
127
127− readSimpleMetaData = map readPair
128+ readSimpleMetaData = map readPair . filter (not . all isSpace)
128 readPair = trimPair . break (== ':')
129 readPair = trimPair . break (== ':')
129 trimPair (key, value) = (trim key, trim $ tail value)
130 trimPair (key, value) = (trim key, trim $ tail value)
130
131
131 readSectionMetaData [] = []
132 readSectionMetaData [] = []
132 readSectionMetaData (header:value) =
133 readSectionMetaData (header:value) =
133− let key = substituteRegex "[^a-zA-Z]" "" header
134+ let key = substituteRegex "[^a-zA-Z0-9]" "" header
134 in [(key, renderFunction $ unlines value)]
135 in [(key, renderFunction $ unlines value)]
135
136
136-- | Read a page from a file. Metadata is supported, and if the filename
137-- | Read a page from a file. Metadata is supported, and if the filename
src/Text/Hakyll/Render/Internal.hs+2−2
@@ -13,7 +13,7 @@ import qualified Data.Map as M
13import Text.Hakyll.Context (Context, ContextManipulation)
13import Text.Hakyll.Context (Context, ContextManipulation)
14import Control.Monad.Reader (liftIO)
14import Control.Monad.Reader (liftIO)
15import Data.List (isPrefixOf, foldl')
15import Data.List (isPrefixOf, foldl')
16−import Data.Char (isAlpha)
16+import Data.Char (isAlphaNum)
17import Data.Maybe (fromMaybe)
17import Data.Maybe (fromMaybe)
18import Control.Parallel.Strategies (rdeepseq, ($|))
18import Control.Parallel.Strategies (rdeepseq, ($|))
19
19
@@ -33,7 +33,7 @@ substitute escaper string context
33 | otherwise = head string : substitute' tail'
33 | otherwise = head string : substitute' tail'
34 where
34 where
35 tail' = tail string
35 tail' = tail string
36− (key, rest) = span isAlpha tail'
36+ (key, rest) = span isAlphaNum tail'
37 replacement = fromMaybe ('$' : key) $ M.lookup key context
37 replacement = fromMaybe ('$' : key) $ M.lookup key context
38 substituteKey = replacement ++ substitute' rest
38 substituteKey = replacement ++ substitute' rest
39 substitute' str = substitute escaper str context
39 substitute' str = substitute escaper str context