From ea1bb417268692a0e005ec331fb938eb445d01d1 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Sat, 27 Feb 2010 17:32:27 +0100 Subject: Readability improvements. --- src/Text/Hakyll/Context.hs | 15 ++++++++------- src/Text/Hakyll/Regex.hs | 3 ++- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'src/Text/Hakyll') diff --git a/src/Text/Hakyll/Context.hs b/src/Text/Hakyll/Context.hs index f84d161..69816b6 100644 --- a/src/Text/Hakyll/Context.hs +++ b/src/Text/Hakyll/Context.hs @@ -59,13 +59,14 @@ renderDate :: String -- ^ Key in which the rendered date should be placed. renderDate key format defaultValue context = M.insert key value context where value = fromMaybe defaultValue pretty - pretty = do filePath <- M.lookup "path" context - let dateString = substituteRegex "^([0-9]*-[0-9]*-[0-9]*).*" "\\1" - (takeFileName filePath) - time <- parseTime defaultTimeLocale - "%Y-%m-%d" - dateString :: Maybe UTCTime - return $ formatTime defaultTimeLocale format time + pretty = do + filePath <- M.lookup "path" context + let dateString = substituteRegex "^([0-9]*-[0-9]*-[0-9]*).*" "\\1" + (takeFileName filePath) + time <- parseTime defaultTimeLocale + "%Y-%m-%d" + dateString :: Maybe UTCTime + return $ formatTime defaultTimeLocale format time -- | Change the extension of a file. This is only needed when you want to -- render, for example, mardown to @.php@ files instead of @.html@ files. diff --git a/src/Text/Hakyll/Regex.hs b/src/Text/Hakyll/Regex.hs index 8706f99..96db2d2 100644 --- a/src/Text/Hakyll/Regex.hs +++ b/src/Text/Hakyll/Regex.hs @@ -41,7 +41,8 @@ subRegex regexp inp replacement = in case matchRegexAll regexp inp of Nothing -> inp Just (lead, match', trail, groups) -> - lead ++ lookup' match' replacement groups ++ subRegex regexp trail replacement + lead ++ lookup' match' replacement groups + ++ subRegex regexp trail replacement -- | Splits a string based on a regular expression. The regular expression -- should identify one delimiter. -- cgit v1.2.3