Ensuring that certain Rules fire before others

21 views
Skip to first unread message

laurent....@gmail.com

unread,
Mar 29, 2019, 9:34:59 PM3/29/19
to hakyll
Hello all,

I've been playing with generating figures from Markdown documents with the pandoc-pyplot filter.

When a blog post gets compiled with this pandoc filter, figures are generated in a new folder called "generated/". I need to move those files into the appropriate directory.

However, the files in the source directory "generated/" are only created AFTER the Markdown posts are compiled with Pandoc.

Therefore, I need the following:

match "posts/*" $ do
    route $ setExtension
"html"
    compile $ pandocCompiler_

>>= loadAndApplyTemplate "templates/post.html" postCtx
       
>>= loadAndApplyTemplate "templates/default.html" postCtx
>>= relativizeUrls

to happen before the following:
match "generated/" $ do
    route   generatedRoute
    compile copyFileCompiler

because at the time of blog post compilation, the "generated/" might be empty / incomplete. I thought about using snapshots first:
match "posts/*" $ do
    route $ setExtension
"html"
    compile $ pandocCompiler_
       
>>= saveSnapshot "compiledPosts"
        >>= loadAndApplyTemplate "templates/post.html" postCtx
       
>>= loadAndApplyTemplate "templates/default.html" postCtx
        >>= relativizeUrls


match
"generated/" $ do 
    route   generatedRoute
    compile (loadAllSnapshots "posts/" "compiledPosts") >> copyFileCompiler

which should ensure that the posts get compiled (and hence, the "generated/" directory gets populated) before hakyll checks the folder for items, but I get an error
 No instance for (base-4.11.1.0:Data.Typeable.Internal.Typeable a0)
        arising
from a use of `loadAllSnapshots'
    * In the first argument of `
(>>)', namely
        `loadAllSnapshots "posts/*" "compiledPosts"'

Any idea on how to ensure that the posts are compiled before the generated content is routed elsewhere? Regards, Laurent





Reply all
Reply to author
Forward
0 new messages