Dicemonger (talk | contribs) mNo edit summary |
Dicemonger (talk | contribs) mNo edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 3: | Line 3: | ||
function p.begin(frame) | function p.begin(frame) | ||
local cols = getCols(frame) | local cols = getCols(frame) | ||
return "<div style=\"column-count:" | return "<div style=\"column-count:" .. cols .. "; column-width:" .. getWidth(cols) .. "; column-gap:40px; column-rule: 2px solid #d6d6d6;\">" | ||
end | end | ||
function p.div(frame) | function p.div(frame) | ||
local cols = getCols(frame) | local cols = getCols(frame) | ||
return "</div><div style=\"column-count:" | return "</div><div style=\"column-count:" .. cols .. "; column-width:" .. getWidth(cols) .. "; column-gap:40px; column-rule: 2px solid #d6d6d6;\">" | ||
end | end | ||
Line 18: | Line 18: | ||
local cols = frame.args['cols'] | local cols = frame.args['cols'] | ||
if cols == nil then | if cols == nil then | ||
return 2 | return "2" | ||
end | end | ||
return cols | return cols | ||
Line 24: | Line 24: | ||
function getWidth(cols) | function getWidth(cols) | ||
if cols == 2 then | if cols == "2" then | ||
return "300px" | return "300px" | ||
elseif cols == 3 then | elseif cols == "3" then | ||
return "200px" | return "200px" | ||
elseif cols == 4 then | elseif cols == "4" then | ||
return "150px" | return "150px" | ||
end | end |
Latest revision as of 15:26, 9 June 2023
Mark sections of text with column-count css.
Functions
begin
{{#invoke:Columns|begin|cols=2}}
This function marks the beginning of a section.
cols | The number of columns (2 to 4). Defaults to 2. |
stop
{{#invoke:Columns|stop}}
This function marks the end of a section. It has no parameters.
div
{{#invoke:Columns|div|cols=2}}
This function is basically "stop" immediately followed by "begin". This creates a break between two sections.
cols | The number of columns (2 to 4). Defaults to 2. |
local p = {}
function p.begin(frame)
local cols = getCols(frame)
return "<div style=\"column-count:" .. cols .. "; column-width:" .. getWidth(cols) .. "; column-gap:40px; column-rule: 2px solid #d6d6d6;\">"
end
function p.div(frame)
local cols = getCols(frame)
return "</div><div style=\"column-count:" .. cols .. "; column-width:" .. getWidth(cols) .. "; column-gap:40px; column-rule: 2px solid #d6d6d6;\">"
end
function p.stop(frame)
return "</div>"
end
function getCols(frame)
local cols = frame.args['cols']
if cols == nil then
return "2"
end
return cols
end
function getWidth(cols)
if cols == "2" then
return "300px"
elseif cols == "3" then
return "200px"
elseif cols == "4" then
return "150px"
end
end
return p