8 local config=require('config') |
8 local config=require('config') |
9 local path=require('path') |
9 local path=require('path') |
10 local filecache=require('filecache') |
10 local filecache=require('filecache') |
11 local log=require('log') |
11 local log=require('log') |
12 local dependency=require('dependency') |
12 local dependency=require('dependency') |
|
13 local pandoc=require('pandoc') |
13 |
14 |
14 -- |
15 -- |
15 -- Phase 1: load & markup |
16 -- Phase 1: load & markup |
16 -- |
17 -- |
17 |
18 |
86 function handlers_render.render(file, env, path_prefix) |
87 function handlers_render.render(file, env, path_prefix) |
87 local data=env.pages[file].data |
88 local data=env.pages[file].data |
88 if data then |
89 if data then |
89 local newenv=handlers_render.env_for(file, env, path_prefix) |
90 local newenv=handlers_render.env_for(file, env, path_prefix) |
90 local data2=handlers_render.process_lua(data, newenv) |
91 local data2=handlers_render.process_lua(data, newenv) |
91 meta=env.pages[file].meta |
92 meta = env.pages[file].meta |
92 if meta.markdown == nil or meta.markdown == "true" then |
93 renderer = meta.renderer or "markdown" |
|
94 print("Renderer", meta.renderer, "\n") |
|
95 if renderer == "pandoc" then |
|
96 return pandoc.pandoc(data2) |
|
97 elseif renderer == "markdown" then |
93 return markdown(data2) |
98 return markdown(data2) |
|
99 elseif renderer == "none" then |
|
100 return data2 |
94 else |
101 else |
95 return data2 |
102 error('Unknown renderer') |
96 end |
103 end |
97 end |
104 end |
98 end |
105 end |
99 |
106 |
100 function handlers_render.phase2(file, env) |
107 function handlers_render.phase2(file, env) |
116 end |
123 end |
117 table.insert(deps, tmpl) |
124 table.insert(deps, tmpl) |
118 build=dependency.simple_update_check(dst, deps) |
125 build=dependency.simple_update_check(dst, deps) |
119 end |
126 end |
120 |
127 |
121 if build then |
128 if build then |
122 log.log("Render "..file.."\n") |
129 log.log("Render "..file.."\n") |
123 local content=handlers_render.render(file, env) |
130 local content=handlers_render.render(file, env, page.meta) |
124 local page_template=filecache.get(tmpl) |
131 local page_template=filecache.get(tmpl) |
125 |
132 |
126 local newenv=table.join({content=content}, handlers_render.env_for(file, env)) |
133 local newenv=table.join({content=content}, handlers_render.env_for(file, env)) |
127 local data2=handlers_render.process_lua(page_template, newenv) |
134 local data2=handlers_render.process_lua(page_template, newenv) |
128 |
135 |