handlers/render.lua

changeset 16
e377590e9b19
parent 15
82d254b8f01e
child 17
bea2ea0b07d9
--- a/handlers/render.lua	Wed Jan 31 19:51:10 2018 +0000
+++ b/handlers/render.lua	Mon Apr 20 11:48:40 2020 -0500
@@ -10,6 +10,7 @@
 local filecache=require('filecache')
 local log=require('log')
 local dependency=require('dependency')
+local pandoc=require('pandoc')
 
 --
 -- Phase 1: load & markup
@@ -88,11 +89,17 @@
     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
-        if meta.markdown == nil or meta.markdown == "true" then
+        meta = env.pages[file].meta
+        renderer = meta.renderer or "markdown"
+        print("Renderer", meta.renderer, "\n")
+        if renderer == "pandoc" then
+            return pandoc.pandoc(data2)
+        elseif renderer == "markdown" then
             return markdown(data2)
+        elseif renderer == "none" then
+            return data2
         else
-            return data2
+            error('Unknown renderer')
         end
     end
 end
@@ -118,9 +125,9 @@
         build=dependency.simple_update_check(dst, deps)
     end
     
-    if build then 
+    if build then
         log.log("Render "..file.."\n")
-        local content=handlers_render.render(file, env)
+        local content=handlers_render.render(file, env, page.meta)
         local page_template=filecache.get(tmpl)
 
         local newenv=table.join({content=content}, handlers_render.env_for(file, env))

mercurial