మాడ్యూల్:Category see also: కూర్పుల మధ్య తేడాలు
Content deleted Content added
output "the categories" before the links if we have more than one link |
better namespace handling for category names, and raise an error for invalid titles |
||
పంక్తి 50:
end
return function (category)
local title = mw.title.new(category)
local pageName, display
if not title then
-- category is not a valid title, usually because of invalid
-- characters like < or [. Raise an error and suppress the stack
-- level information so that we can catch it and format the error
-- message as wikitext.
error(string.format(
"'%s' is not a valid category name",
category
), 0)
elseif title.namespace == 14 then -- Category namespace
pageName = title.text
display = title.text
else
pageName = title.prefixedText
display = category
end
-- We can get away with using two arguments even when
-- options.showDisplay is false, as string.format ignores extra
-- arguments as long as there is an argument for each flag in the
-- format string.
return formatString:format(
end
end
Line 72 ⟶ 90:
local links = {}
for i, cat in ipairs(args) do
local success, categoryLink = pcall(makeCategoryLink, cat)
if success then
links[i] = categoryLink
else
-- If there was an error, then categoryLink is the error message.
return makeWikitextError(categoryLink)
end
end
|