Module:InternalLinkCounter

-- This Lua module provides a function to count the number of internal links in a given wikitext.
-- This is used by [[Template:InternalLinkCounter]].

local p = {}

-- Function to count the number of internal links in the provided wikitext.
function p.main(frame)
    local text = frame.args[1] or ""
    local count = 0
    -- Iterating through the wikitext to find internal link patterns.
    for link in mw.ustring.gmatch(text, "%[%[([^%]]+)%]%]") do
        count = count + 1
    end
    -- Returning the total count of internal links.
    return count
end

-- Returning the module table.
return p

Module:InternalLinkCounter



Share this article:

This article uses material from the Wikipedia article Module:InternalLinkCounter, and is written by contributors. Text is available under a CC BY-SA 4.0 International License; additional terms may apply. Images, videos and audio are available under their respective licenses.