Dicemonger (talk | contribs) (Created page with "local p = {} function p.hello(frame) return "Hello, world!" end return p") |
Dicemonger (talk | contribs) mNo edit summary |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
function p. | function p.begin(frame) | ||
return " | 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 | end | ||
return p | return p |
Revision as of 15:13, 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