Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:IncreaseHeadings: Difference between revisions

From Teriock
Content deleted Content added
m Gpe moved page Module:H to Module:IncreaseHeadings without leaving a redirect
No edit summary
Line 3: Line 3:
function p.increaseHeadings(frame)
function p.increaseHeadings(frame)
local content = frame.args[1] or ''
local content = frame.args[1] or ''
-- Replace headings with one level higher (e.g., == becomes ===)
-- Replace headings with custom wrapping {{ }}
content = mw.ustring.gsub(content, '^(=+)(.-)(=+)$', function(eq1, text, eq2)
content = mw.ustring.gsub(content, '^(=+)(.-)(=+)$', function(eq1, text, eq2)
if #eq1 == #eq2 then
if #eq1 == #eq2 then
local newLevel = eq1 .. '='
return '((' .. text .. '))'
return newLevel .. text .. newLevel
else
else
return eq1 .. text .. eq2
return eq1 .. text .. eq2

Revision as of 01:38, 26 December 2024

Documentation for this module may be created at Module:IncreaseHeadings/doc

local p = {}

function p.increaseHeadings(frame)
    local content = frame.args[1] or ''
    -- Replace headings with custom wrapping {{ }}
    content = mw.ustring.gsub(content, '^(=+)(.-)(=+)$', function(eq1, text, eq2)
        if #eq1 == #eq2 then
            return '((' .. text .. '))'
        else
            return eq1 .. text .. eq2
        end
    end)
    return content
end

return p