local content = self:readall(file)
if ngx.ctx.tmpl_content then content = ngx.ctx.tmpl_content end
if not content then return end
+ if ngx.var.request_uri:match('^/dev/') then
+ --content = template.compile(content,vars)(context)
+ --ngx.print(content)
+ --return
+ end
local ishtml = true
- if false then
+ if false and string.match(file,'%.md$') then
template.markdown = require "resty.hoedown"
-- ngx.say('zaza' .. template.markdown.html.flags.table)
--content = self:md2html(content)
elseif string.match(file,'%.html?$') then
local i = '<[^>]+>'
-- Extract title from h1
- if not vars.title then vars.title = string.match(content,'<h1[^>]*>([^>]+)</h1>',1) end
+ if not vars.title then vars.title = string.match(content:gsub('(<h1[^>]*>)<[^>]+>','%1'),'<h1[^>]*>([^<>]+)',1) end
-- Extract title from h2
- if not vars.title then vars.title = string.match(content,'<h2[^>]*>([^>]+)</h2>',1) end
+ if not vars.title then vars.title = string.match(content:gsub('(<h2[^>]*>)<[^>]+>','%1'),'<h2[^>]*>([^<>]+)',1) end
elseif not ngx.ctx.tmpl_content then
ishtml = false