alpha p1
This commit is contained in:
41
core/std.lua
41
core/std.lua
@@ -17,9 +17,17 @@ function M.site_version()
|
||||
end
|
||||
|
||||
function M.a(link, str)
|
||||
link = link or "https://example.com"
|
||||
str = str or link
|
||||
return "<a href=\"" .. link .. "\">" .. str .. "</a>"
|
||||
end
|
||||
|
||||
function M.ha(link, str)
|
||||
link = link or "https://example.com"
|
||||
str = str or link
|
||||
return "<a class=\"hidden\" href=\"" .. link .. "\">" .. str .. "</a>"
|
||||
end
|
||||
|
||||
function M.external(link, str)
|
||||
return "<a target=\"_blank\" href=\"" .. link .. "\">" .. str .. "</a>"
|
||||
end
|
||||
@@ -92,6 +100,16 @@ function M.ol(items)
|
||||
return html
|
||||
end
|
||||
|
||||
function M.tl(items)
|
||||
items = items or {}
|
||||
local html = '<ul class="tl">'
|
||||
for _, item in ipairs(items) do
|
||||
html = html .. "<li>" .. tostring(item) .. "</li>"
|
||||
end
|
||||
html = html .. "</ul>"
|
||||
return html
|
||||
end
|
||||
|
||||
function M.blockquote(str)
|
||||
return "<blockquote>" .. (str or "") .. "</blockquote>"
|
||||
end
|
||||
@@ -191,13 +209,13 @@ end
|
||||
function M.table(headers, rows)
|
||||
headers = headers or {}
|
||||
rows = rows or {}
|
||||
|
||||
|
||||
local html = "<table><thead><tr>"
|
||||
for _, header in ipairs(headers) do
|
||||
html = html .. "<th>" .. tostring(header) .. "</th>"
|
||||
end
|
||||
html = html .. "</tr></thead><tbody>"
|
||||
|
||||
|
||||
for _, row in ipairs(rows) do
|
||||
html = html .. "<tr>"
|
||||
for _, cell in ipairs(row) do
|
||||
@@ -205,7 +223,7 @@ function M.table(headers, rows)
|
||||
end
|
||||
html = html .. "</tr>"
|
||||
end
|
||||
|
||||
|
||||
html = html .. "</tbody></table>"
|
||||
return html
|
||||
end
|
||||
@@ -215,7 +233,24 @@ function M.copyright()
|
||||
end
|
||||
|
||||
function M.highlight(str)
|
||||
str = str or ""
|
||||
return '<span class="highlight">' .. str .. "</span>"
|
||||
end
|
||||
|
||||
function M.banner(str)
|
||||
str = str or ""
|
||||
return '<div class="banner">' .. str .. "</div>"
|
||||
end
|
||||
|
||||
function M.center(str)
|
||||
str = str or ""
|
||||
return '<div class="center">' .. str .. "</div>"
|
||||
end
|
||||
|
||||
function M.nav(link, str)
|
||||
link = link or "example.com"
|
||||
str = str or link
|
||||
return '<a class="nav" href="' .. link .. '">' .. str .. "</a>"
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
Reference in New Issue
Block a user