Module:Category handler: Difference between revisions
add namespace alias handling, so main-namespace can be specified |
ArrowHead294 (talk | contribs) m Wikitext debugger option |
||
| (One intermediate revision by one other user not shown) | |||
| Line 134: | Line 134: | ||
-- Disallows categories if it's in a suppressed namespace or the page has a | -- Disallows categories if it's in a suppressed namespace or the page has a | ||
-- suppressed suffix (subpage) | -- suppressed suffix (subpage) | ||
function p._category_handler(cats, ns_override, suffixes | function p._category_handler(cats, is_debug, ns_override, suffixes) | ||
local cats = cats or {} | local cats = cats or {} | ||
local is_debug = yesno(is_debug, false) | local is_debug = yesno(is_debug, false) | ||
| Line 165: | Line 165: | ||
function p.category_handler(frame) | function p.category_handler(frame) | ||
local args = getArgs(frame) | local args = getArgs(frame) | ||
local excluded_ns_unparsed = args["excluded_ns"] or "" -- Additional namespaces to exclude (EG, a template that should not be used within main namespace, which is allowed by default) | local excluded_ns_unparsed = args["excluded_ns"] or "" -- Additional namespaces to exclude (EG, a template that should not be used within main namespace, which is allowed by default) | ||
local allowed_ns_unparsed = args["allowed_ns" ] or "" -- Namespaces to allow; overrides default list (EG, a template that should be used within user namespace, which is disallowed by default) | local allowed_ns_unparsed = args["allowed_ns" ] or "" -- Namespaces to allow; overrides default list (EG, a template that should be used within user namespace, which is disallowed by default) | ||
local suffixes_unparsed = args["suffixes" ] or "" -- Additional page suffixes in which to disallow categories | local suffixes_unparsed = args["suffixes" ] or "" -- Additional page suffixes in which to disallow categories | ||
local is_debug = yesno(args["debug"], false) | local is_debug = yesno(args["debug"], false) -- Parse debug mode; setting this to TRUE disables all categories | ||
local wtext = yesno(args["wtext"]) -- Used to show the underlying Wikitext | |||
-- Parse categories | -- Parse categories | ||
| Line 212: | Line 213: | ||
end | end | ||
local result = p._category_handler(cats, is_debug, ns_override, suffixes) | |||
if wtext then | |||
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>" | |||
end | |||
return frame:preprocess(result) | |||
end | end | ||
return p | return p | ||