on master help sign in
Fix typo in comments
d25dcb6Jasper Van der Jeugt
src/Hakyll/Web/Page/Read.hs+5−7
@@ -18,11 +18,6 @@ import Hakyll.Web.Util.String
18--
18--
19type LineParser = State [String]
19type LineParser = State [String]
20
20
21−-- | Check if the given string is a metadata delimiter.
22−--
23−isPossibleDelimiter :: String -> Bool
24−isPossibleDelimiter = isPrefixOf "---"
25−
26-- | Read the metadata section from a page
21-- | Read the metadata section from a page
27--
22--
28parseMetadata :: LineParser (Map String String)
23parseMetadata :: LineParser (Map String String)
@@ -31,7 +26,7 @@ parseMetadata = get >>= \content -> case content of
31 [] -> return M.empty
26 [] -> return M.empty
32 -- Check if the file begins with a delimiter
27 -- Check if the file begins with a delimiter
33 (l : ls) -> if not (isPossibleDelimiter l)
28 (l : ls) -> if not (isPossibleDelimiter l)
34− then -- No delimiter means no body
29+ then -- No delimiter means no metadata
35 return M.empty
30 return M.empty
36 else do -- Break the metadata section
31 else do -- Break the metadata section
37 let (metadata, rest) = second (drop 1) $ break (== l) ls
32 let (metadata, rest) = second (drop 1) $ break (== l) ls
@@ -40,7 +35,10 @@ parseMetadata = get >>= \content -> case content of
40 -- Parse the metadata
35 -- Parse the metadata
41 return $ M.fromList $ map parseMetadata' metadata
36 return $ M.fromList $ map parseMetadata' metadata
42 where
37 where
43− parseMetadata' :: String -> (String, String)
38+ -- Check if a line can be a delimiter
39+ isPossibleDelimiter = isPrefixOf "---"
40+
41+ -- Parse a "key: value" string to a (key, value) tupple
44 parseMetadata' = (trim *** trim . drop 1) . break (== ':')
42 parseMetadata' = (trim *** trim . drop 1) . break (== ':')
45
43
46-- | Read the body section of a page
44-- | Read the body section of a page