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

Module:HeaderIncrementer: Difference between revisions

From Teriock
Content deleted Content added
Created page with "local p = {} -- Function to adjust headings function p.incrementHeadings(frame) -- Get the content from named argument "content" local content = frame.args.content or "No content provided." -- Increment heading levels local incrementedContent = content:gsub("(=%s*)(.-)(%s*=)", function(leadingEquals, text, trailingEquals) local headingLevel = #leadingEquals -- Count the number of `=` signs if headingLevel < 6 then local newEq..."
 
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
local p = {}
local p = {}


-- Function to adjust headings
function p.incrementHeadings(frame)
function p.incrementHeadings(frame)
-- Get the content from named argument "content"
-- Get the content
local content = frame.args.content or "No content provided."
local content = frame.args.content or "No content provided."



Latest revision as of 03:04, 26 December 2024

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

local p = {}

function p.incrementHeadings(frame)
    -- Get the content
    local content = frame.args.content or "No content provided."

    -- Increment heading levels
    local incrementedContent = content:gsub("(=%s*)(.-)(%s*=)", function(leadingEquals, text, trailingEquals)
        local headingLevel = #leadingEquals -- Count the number of `=` signs
        if headingLevel < 6 then
            local newEquals = string.rep("=", headingLevel + 1)
            return newEquals .. text .. newEquals
        else
            return leadingEquals .. text .. trailingEquals
        end
    end)

    return incrementedContent
end

return p