handlers/render.lua

changeset 30
3ac53da03439
parent 29
d4b0773f5e06
child 42
260f867d46c0
--- a/handlers/render.lua	Mon Jul 06 13:34:06 2020 -0500
+++ b/handlers/render.lua	Fri Jul 17 10:00:47 2020 -0500
@@ -92,13 +92,12 @@
     return newenv
 end
 
-function handlers_render.render(file, env, path_prefix)
+function handlers_render.render(file, env, path_prefix, renderer)
     local data=env.pages[file].data
     if data then
         local newenv=handlers_render.env_for(file, env, path_prefix)
         local data2=handlers_render.process_lua(data, newenv)
         meta = env.pages[file].meta
-        renderer = meta.renderer or "markdown-it"
         if renderer == "markdown-it" then
             return markdown_it.markdown(data2, env)
         elseif renderer == "pandoc" then
@@ -119,6 +118,8 @@
     local dst = path.join(env.paths.dst, page.destination)
     local tmpl = path.join(env.paths.tmpl,
                            page.meta.template or "page.template")
+    renderer = page.meta.renderer or "markdown-it"
+
     local deps = {src}
     
     local build=page.meta.always_build
@@ -131,12 +132,15 @@
             end
         end
         table.insert(deps, tmpl)
+        if renderer=="markdown-it" then
+            markdown_it.add_deps(deps, env)
+        end
         build=dependency.simple_update_check(dst, deps)
     end
     
     if build then
         log.log("Render "..file.."\n")
-        local content=handlers_render.render(file, env, page.meta)
+        local content=handlers_render.render(file, env, page.meta, renderer)
         local page_template=filecache.get(tmpl)
 
         local newenv=table.join({content=content}, handlers_render.env_for(file, env))

mercurial