doc: first
This commit is contained in:
40
core/std.lua
40
core/std.lua
@@ -186,46 +186,6 @@ function M.site_authors()
|
||||
return {}
|
||||
end
|
||||
|
||||
-- Join array with separator
|
||||
function M.join(arr, sep)
|
||||
arr = arr or {}
|
||||
sep = sep or ", "
|
||||
local result = {}
|
||||
for _, v in ipairs(arr) do
|
||||
table.insert(result, tostring(v))
|
||||
end
|
||||
return table.concat(result, sep)
|
||||
end
|
||||
|
||||
-- Trim whitespace
|
||||
function M.trim(str)
|
||||
str = tostring(str or "")
|
||||
return str:match("^%s*(.-)%s*$")
|
||||
end
|
||||
|
||||
-- Table HTML generator
|
||||
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
|
||||
html = html .. "<td>" .. tostring(cell) .. "</td>"
|
||||
end
|
||||
html = html .. "</tr>"
|
||||
end
|
||||
|
||||
html = html .. "</tbody></table>"
|
||||
return html
|
||||
end
|
||||
|
||||
function M.highlight(str)
|
||||
return '<span class="highlight">' .. (str or "") .. "</span>"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user