]> git.nbdom.net Git - nb.git/commitdiff
lib/lua/nb.lua
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 1 May 2018 03:46:29 +0000 (04:46 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 1 May 2018 03:46:29 +0000 (04:46 +0100)
lib/lua/nb.lua

index 59e7c1d7ea266c1d7b4ec679151ff1079813c57d..4b80bf90697132035879b4329b82d82f220a8c7d 100644 (file)
@@ -44,7 +44,16 @@ function nb:ngx_location_md()
        if string.match(file,'%.md$') then
                -- Markdown
                discount = require("discount")
-               ngx.print(discount(content))
+               content = discount(content)
+               local tags = { 'th', 'td' }
+               -- for tag in self:values(tags) do
+                       -- content = content:gsub(" +(</th>)","%1")
+               -- end
+               content = content:gsub(" +(</th>)","%1")
+               content = content:gsub("(<th>) +","%1")
+               content = content:gsub(" +(</td>)","%1")
+               content = content:gsub("(<td>) +","%1")
+               ngx.print(content)
 
        elseif string.match(file,'%.html$') then
                -- Html
@@ -59,6 +68,10 @@ function nb:ngx_location_md()
        ngx.exit(0)
 end
 
+function values(t)
+  local i = 0
+  return function() i = i + 1; return t[i] end
+end
 -- function nb:ngx_vars()
 --     local vars = {}
 --     vars = {