Module:Quote: Difference between revisions
From Heterodontosaurus Balls
m Removed protection from "Module:Quote" |
Test Tag: Reverted |
||
| Line 1: | Line 1: | ||
local | local p = {} | ||
local function | -- Helper function to map size keywords to pixel values | ||
local function getSizeValue(size) | |||
local map = { | |||
["10px"] = { pad = "40px", font = "20px" }, | |||
["30px"] = { pad = "60px", font = "60px" }, | |||
["40px"] = { pad = "70px", font = "80px" }, | |||
["50px"] = { pad = "80px", font = "100px" }, | |||
["60px"] = { pad = "90px", font = "120px" } | |||
} | |||
return map[size] or { pad = "50px", font = "36px" } | |||
end | end | ||
function p.main(frame) | |||
local args = frame:getParent().args | |||
local quote = args[1] or "Insert the text of the quote here, without quotation marks" | |||
local author = args[2] | |||
local size = args.size or args[3] or args.quotewidth or args.width or "20px" | |||
local sizes = getSizeValue(size) | |||
local out = {} | |||
table.insert(out, '<table style="margin: auto; border-collapse:collapse; border-style:none; background-color:transparent;" class="cquote">') | |||
table.insert(out, '<tr><td>') | |||
table.insert(out, '<div style="padding:4px ' .. sizes.pad .. ';position:relative;">') | |||
table.insert(out, '<span style="position:absolute;left:10px;top:-6px;z-index:1;font-family:\'Times New Roman\',serif;font-weight:bold;color:#B2B7F2;font-size:' .. sizes.font .. ';">“</span>') | |||
table.insert(out, '<span style="position:absolute;right:10px;bottom:-16px;z-index:1;font-family:\'Times New Roman\',serif;font-weight:bold;color:#B2B7F2;font-size:' .. sizes.font .. ';">”</span>') | |||
table.insert(out, '<span style="font-size:16px;">' .. quote .. '</span>') | |||
table.insert(out, '</div></td></tr>') | |||
if author and author ~= "" then | |||
table.insert(out, '<tr><td style="padding:4px 10px 8px;font-size:14px;line-height:1.6em;text-align:right;">— ' .. author .. '</td></tr>') | |||
end | |||
end | |||
table.insert(out, '</table>') | |||
return table.concat(out, "") | |||
end | end | ||
return | return p | ||
Revision as of 07:35, 11 November 2025
Documentation for this module may be created at Module:Quote/doc
local p = {}
-- Helper function to map size keywords to pixel values
local function getSizeValue(size)
local map = {
["10px"] = { pad = "40px", font = "20px" },
["30px"] = { pad = "60px", font = "60px" },
["40px"] = { pad = "70px", font = "80px" },
["50px"] = { pad = "80px", font = "100px" },
["60px"] = { pad = "90px", font = "120px" }
}
return map[size] or { pad = "50px", font = "36px" }
end
function p.main(frame)
local args = frame:getParent().args
local quote = args[1] or "Insert the text of the quote here, without quotation marks"
local author = args[2]
local size = args.size or args[3] or args.quotewidth or args.width or "20px"
local sizes = getSizeValue(size)
local out = {}
table.insert(out, '<table style="margin: auto; border-collapse:collapse; border-style:none; background-color:transparent;" class="cquote">')
table.insert(out, '<tr><td>')
table.insert(out, '<div style="padding:4px ' .. sizes.pad .. ';position:relative;">')
table.insert(out, '<span style="position:absolute;left:10px;top:-6px;z-index:1;font-family:\'Times New Roman\',serif;font-weight:bold;color:#B2B7F2;font-size:' .. sizes.font .. ';">“</span>')
table.insert(out, '<span style="position:absolute;right:10px;bottom:-16px;z-index:1;font-family:\'Times New Roman\',serif;font-weight:bold;color:#B2B7F2;font-size:' .. sizes.font .. ';">”</span>')
table.insert(out, '<span style="font-size:16px;">' .. quote .. '</span>')
table.insert(out, '</div></td></tr>')
if author and author ~= "" then
table.insert(out, '<tr><td style="padding:4px 10px 8px;font-size:14px;line-height:1.6em;text-align:right;">— ' .. author .. '</td></tr>')
end
table.insert(out, '</table>')
return table.concat(out, "")
end
return p
