diff options
context:
space:
mode:
Diffstat (limited to 'custom/extensions')
-rw-r--r--custom/extensions/about-render.lua80
-rw-r--r--custom/extensions/auth-file.lua2
-rw-r--r--custom/extensions/auth-inline.lua2
3 files changed, 59 insertions, 25 deletions
diff --git a/custom/extensions/about-render.lua b/custom/extensions/about-render.lua
index 805265e..c833c00 100644
--- a/custom/extensions/about-render.lua
+++ b/custom/extensions/about-render.lua
@@ -115,8 +115,11 @@ emit_inline = function(list)
elseif kind == "image" then
local target = safe_url(node.url)
if target then
- html("<img src='"); html_attr(target)
- html("' alt='"); html_attr(node.alt); html("'>")
+ html("<img src='")
+ html_attr(target)
+ html("' alt='")
+ html_attr(node.alt)
+ html("'>")
else
html_txt("![" .. node.alt .. "]")
end
@@ -138,9 +141,13 @@ emit_blocks = function(blocks)
elseif kind == "code" then
html("<pre><code")
if block.lang and block.lang ~= "" then
- html(" data-lang='"); html_attr(block.lang); html("'")
+ html(" data-lang='")
+ html_attr(block.lang)
+ html("'")
end
- html(">"); html_txt(block.text); html("</code></pre>")
+ html(">")
+ html_txt(block.text)
+ html("</code></pre>")
elseif kind == "blockquote" then
html("<blockquote>")
emit_blocks(block.blocks)
@@ -148,13 +155,17 @@ emit_blocks = function(blocks)
elseif kind == "table" then
html("<table><thead><tr>")
for _, cell in ipairs(block.head) do
- html("<th>"); emit_inline(cell); html("</th>")
+ html("<th>")
+ emit_inline(cell)
+ html("</th>")
end
html("</tr></thead><tbody>")
for _, row in ipairs(block.rows) do
html("<tr>")
for _, cell in ipairs(row) do
- html("<td>"); emit_inline(cell); html("</td>")
+ html("<td>")
+ emit_inline(cell)
+ html("</td>")
end
html("</tr>")
end
@@ -163,13 +174,17 @@ emit_blocks = function(blocks)
local tag = block.ordered and "ol" or "ul"
html("<" .. tag .. ">")
for _, item in ipairs(block.items) do
- html("<li>"); emit_inline(item); html("</li>")
+ html("<li>")
+ emit_inline(item)
+ html("</li>")
end
html("</" .. tag .. ">")
elseif kind == "para" then
html("<p>")
for i, line in ipairs(block.lines) do
- if i > 1 then html("<br>") end
+ if i > 1 then
+ html("<br>")
+ end
emit_inline(line)
end
html("</p>")
@@ -300,11 +315,14 @@ if has_lpeg then
local code = {}
i = i + 1
while i <= n and not close:match(lines[i]) do
- code[#code + 1] = lines[i]; i = i + 1
+ code[#code + 1] = lines[i]
+ i = i + 1
end
i = i + 1
local body = table.concat(code, "\n")
- if #code > 0 then body = body .. "\n" end
+ if #code > 0 then
+ body = body .. "\n"
+ end
blocks[#blocks + 1] = {
kind = "code",
lang = lang,
@@ -453,9 +471,14 @@ if has_lpeg then
local tokens = man_inline_grammar:match(text) or {}
local nodes, parts, font = {}, {}, "R"
local function flush()
- if #parts == 0 then return end
- local run = table.concat(parts); parts = {}
- if run == "" then return end
+ if #parts == 0 then
+ return
+ end
+ local run = table.concat(parts)
+ parts = {}
+ if run == "" then
+ return
+ end
if font == "B" then
nodes[#nodes + 1] = {
kind = "strong",
@@ -474,7 +497,8 @@ if has_lpeg then
if token.kind == "text" then
parts[#parts + 1] = token.text
elseif token.kind == "font" then
- flush(); font = token.font
+ flush()
+ font = token.font
end
end
flush()
@@ -494,7 +518,9 @@ if has_lpeg then
local function flush_nofill()
if nofill_lines then
local body = table.concat(nofill_lines, "\n")
- if #nofill_lines > 0 then body = body .. "\n" end
+ if #nofill_lines > 0 then
+ body = body .. "\n"
+ end
blocks[#blocks + 1] = { kind = "code", text = body }
nofill_lines = nil
end
@@ -505,10 +531,13 @@ if has_lpeg then
end
for _, line in ipairs(lines) do
local macro, rest = macro_line:match(line)
- if rest then rest = (rest:gsub('^"(.*)"$', "%1")) end
+ if rest then
+ rest = (rest:gsub('^"(.*)"$', "%1"))
+ end
if nofill then
if macro == "fi" then
- nofill = false; flush_nofill()
+ nofill = false
+ flush_nofill()
else
nofill_lines[#nofill_lines + 1] = line
end
@@ -524,7 +553,9 @@ if has_lpeg then
kids = man_inline(rest),
}
elseif macro == "nf" then
- flush_paragraph(); nofill = true; nofill_lines = {}
+ flush_paragraph()
+ nofill = true
+ nofill_lines = {}
elseif macro == "fi" then
flush_nofill()
elseif macro == "B" or macro == "BR" or macro == "RB" or macro == "BI" or macro == "IB" then
@@ -532,17 +563,20 @@ if has_lpeg then
elseif macro == "I" or macro == "IR" or macro == "RI" then
add_line({ { kind = "em", kids = man_inline(rest) } })
elseif macro == "TH" or macro == "PP" or macro == "LP"
- or macro == "P" or macro == "TP" or macro == "IP"
- or macro == "HP" or macro == "RS" or macro == "RE"
- or macro == "sp" or macro == "br" then
+ or macro == "P" or macro == "TP" or macro == "IP"
+ or macro == "HP" or macro == "RS" or macro == "RE"
+ or macro == "sp" or macro == "br" then
flush_paragraph()
elseif macro then
- if rest ~= "" then add_line(man_inline(rest)) end
+ if rest ~= "" then
+ add_line(man_inline(rest))
+ end
else
add_line(man_inline(line))
end
end
- flush_paragraph(); flush_nofill()
+ flush_paragraph()
+ flush_nofill()
return blocks
end
diff --git a/custom/extensions/auth-file.lua b/custom/extensions/auth-file.lua
index 230aa6d..3d426e9 100644
--- a/custom/extensions/auth-file.lua
+++ b/custom/extensions/auth-file.lua
@@ -405,7 +405,7 @@ function set_cookie(cookie, value)
end
function redirect_to(url)
- html("Status: 302 Redirect\n")
+ html("Status: 302 Found\n")
html("Cache-Control: no-cache, no-store\n")
html("Location: " .. strip_controls(url) .. "\n")
end
diff --git a/custom/extensions/auth-inline.lua b/custom/extensions/auth-inline.lua
index 0ae2cb8..5363a38 100644
--- a/custom/extensions/auth-inline.lua
+++ b/custom/extensions/auth-inline.lua
@@ -366,7 +366,7 @@ function set_cookie(cookie, value)
end
function redirect_to(url)
- html("Status: 302 Redirect\n")
+ html("Status: 302 Found\n")
html("Cache-Control: no-cache, no-store\n")
html("Location: " .. strip_controls(url) .. "\n")
end