Module:Slideshow: Difference between revisions
Appearance
Created page with "local p = {} local function trim(s) return mw.text.trim(s or "") end function p.render(frame) local args = frame.args local items = args.items or args[1] or "" if trim(items) == "" then return "" end local output = {} table.insert(output, '<gallery mode="slideshow">') for line in mw.text.gsplit(items, "\n", true) do line = trim(line) if line ~= "" then local filename, caption = line:match("^(.-)%s*::%s*(.*)$") if filename then filename = tr..." |
No edit summary |
||
| Line 14: | Line 14: | ||
local output = {} | local output = {} | ||
table.insert(output, '<gallery mode="slideshow">') | table.insert(output, '<gallery mode="slideshow" class="adaris-slideshow">') | ||
for line in mw.text.gsplit(items, "\n", true) do | for line in mw.text.gsplit(items, "\n", true) do | ||
Latest revision as of 02:28, 12 October 2026
Documentation for this module may be created at Module:Slideshow/doc
local p = {}
local function trim(s)
return mw.text.trim(s or "")
end
function p.render(frame)
local args = frame.args
local items = args.items or args[1] or ""
if trim(items) == "" then
return ""
end
local output = {}
table.insert(output, '<gallery mode="slideshow" class="adaris-slideshow">')
for line in mw.text.gsplit(items, "\n", true) do
line = trim(line)
if line ~= "" then
local filename, caption = line:match("^(.-)%s*::%s*(.*)$")
if filename then
filename = trim(filename)
caption = trim(caption)
if not filename:match("^File:") and not filename:match("^Image:") then
filename = "File:" .. filename
end
table.insert(output, filename .. "|" .. caption)
else
if not line:match("^File:") and not line:match("^Image:") then
line = "File:" .. line
end
table.insert(output, line)
end
end
end
table.insert(output, "</gallery>")
return table.concat(output, "\n")
end
return p