Module:category link

From Linguifex
Revision as of 10:14, 9 May 2026 by Sware (talk | contribs) (Created page with "local concat = table.concat local html_create = mw.html.create local is_internal_title = require("Module:pages").is_internal_title local make_title = mw.title.makeTitle local tostring = tostring local export = {} function export.make_link(name, sortkey) -- Unconditionally add the "Category:" prefix. local fullname = "Category:" .. name if is_internal_title(make_title(14, name)) then fullname = "" .. fullname .. "" end return tostring(html_create("code")...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


local concat = table.concat
local html_create = mw.html.create
local is_internal_title = require("Module:pages").is_internal_title
local make_title = mw.title.makeTitle
local tostring = tostring

local export = {}

function export.make_link(name, sortkey)
	-- Unconditionally add the "Category:" prefix.
	local fullname = "Category:" .. name
	if is_internal_title(make_title(14, name)) then
		fullname = "[[:" .. fullname .. "]]"
	end
	
	return tostring(html_create("code")
		:css("white-space", "pre-wrap")
		:wikitext("[[" .. concat({fullname, sortkey}, "|") .. "]]")
	)
end

return export