Module:IncreaseHeadings: Difference between revisions
From Teriock
More actions
No edit summary |
No edit summary |
||
| Line 2: | Line 2: | ||
function p.increaseHeadings(frame) | function p.increaseHeadings(frame) | ||
local | -- Get the raw wikitext of the transcluded page | ||
-- Replace headings with custom wrapping | local pageContent = frame:expandTemplate{ title = frame.args[1] } or '' | ||
-- Replace headings with custom wrapping or increase levels | |||
pageContent = mw.ustring.gsub(pageContent, '^(=+)(.-)(=+)$', function(eq1, text, eq2) | |||
if #eq1 == #eq2 then | if #eq1 == #eq2 then | ||
local newLevel = eq1 .. '=' | |||
return newLevel .. text .. newLevel | |||
else | else | ||
return eq1 .. text .. eq2 | return eq1 .. text .. eq2 | ||
end | end | ||
end) | end) | ||
return | |||
return pageContent | |||
end | end | ||
return p | return p | ||
Revision as of 01:39, 26 December 2024
Documentation for this module may be created at Module:IncreaseHeadings/doc
local p = {}
function p.increaseHeadings(frame)
-- Get the raw wikitext of the transcluded page
local pageContent = frame:expandTemplate{ title = frame.args[1] } or ''
-- Replace headings with custom wrapping or increase levels
pageContent = mw.ustring.gsub(pageContent, '^(=+)(.-)(=+)$', function(eq1, text, eq2)
if #eq1 == #eq2 then
local newLevel = eq1 .. '='
return newLevel .. text .. newLevel
else
return eq1 .. text .. eq2
end
end)
return pageContent
end
return p