@@ -111,7 +111,7 @@ module Hakyll.Core.Compiler
111111 , traceShowCompiler
112112 , mapCompiler
113113 , timedCompiler
114− , byIdentifier
114+ , byPattern
115115 , byExtension
116116 ) where
117117
@@ -348,20 +348,19 @@ timedCompiler msg (Compiler d j) = Compiler d $ \x -> CompilerM $ do
348348-- For example, assume that most content files need to be compiled
349349-- normally, but a select few need an extra step in the pipeline:
350350--
351−-- > compile $ pageCompiler
352−-- > >>> byIdentifier id
353−-- > [ ((=="projects.md") . toFilePath, addProjectListCompiler)
354−-- > , ((=="sitemap.md") . toFilePath, addSiteMapCompiler)
355−-- > ]
351+-- > compile $ pageCompiler >>> byPattern id
352+-- > [ ("projects.md", addProjectListCompiler)
353+-- > , ("sitemap.md", addSiteMapCompiler)
354+-- > ]
356355--
357−byIdentifier :: Compiler a b -- ^ Default compiler
358− -> [(Identifier a -> Bool, Compiler a b)] -- ^ Choices
359− -> Compiler a b -- ^ Resulting compiler
360−byIdentifier defaultCompiler choices = Compiler deps job
356+byPattern :: Compiler a b -- ^ Default compiler
357+ -> [(Pattern (), Compiler a b)] -- ^ Choices
358+ -> Compiler a b -- ^ Resulting compiler
359+byPattern defaultCompiler choices = Compiler deps job
361360 where
362361 -- Lookup the compiler, give an error when it is not found
363− lookup' identifier =
364− maybe defaultCompiler snd $ find (\(f,_) -> f identifier) choices
362+ lookup' identifier = maybe defaultCompiler snd $
363+ find (\(p, _) -> matches p identifier) choices
365364 -- Collect the dependencies of the choice
366365 deps = do
367366 identifier <- castIdentifier . dependencyIdentifier <$> ask
@@ -388,5 +387,6 @@ byIdentifier defaultCompiler choices = Compiler deps job
388387byExtension :: Compiler a b -- ^ Default compiler
389388 -> [(String, Compiler a b)] -- ^ Choices
390389 -> Compiler a b -- ^ Resulting compiler
391−byExtension defaultCompiler = byIdentifier defaultCompiler . map (first cmp)
392− where cmp c = (==c) . takeExtension . toFilePath
390+byExtension defaultCompiler = byPattern defaultCompiler . map (first extPattern)
391+ where
392+ extPattern c = predicate $ (== c) . takeExtension . toFilePath