Content deleted Content added
simplifying regex and assignment Tag: Reverted |
Shonebrooks (talk | contribs) m I corrected the spelling of "Canadian." WP:TYPO |
||
(9 intermediate revisions by 3 users not shown) | |||
Line 1:
--[[
v01.18: fix handling of definite article (e.g. for 'the Northwest Territories')
2.0 Resolve category redirects
each title consists of 3 parts
Line 39 ⟶ 40:
-- globals for this module
local debugging =
local debugmsg = ""
local tableRowNum = 0
Line 55 ⟶ 56:
local getArgs = require('Module:Arguments').getArgs
local yesno = require('Module:Yesno')
local ResolveCategoryRedirect = require('Module:Resolve category redirect').rtarget
local p = {}
Line 91 ⟶ 93:
local function publishDebugLog()
if not debugging then
return "NOT DEBUGGING\n"
end
return "==Debugging ==\n\n" .. debugmsg .. "\n== Output ==\n"
Line 221 ⟶ 223:
debugLog(4, "No. " .. tostring(i) .. ": [" .. aProvince .. "]")
myCatName = makeCatName(aProvince, title_prefix, title_suffix)
myResolvedCatName = ResolveCategoryRedirect(makeCatName(aProvince, title_prefix, title_suffix))
debugLog(5, myCatName .. "--> " ..myResolvedCatName)
table.insert(list_args, makeCatLink(myCatName, aProvince))
end
Line 238 ⟶ 242:
local function patternSearchEncode(s)
return mw.ustring.gsub(s, "([%W])", "%%%1")
end
Line 279 ⟶ 283:
debugLog(4, "match at start, followed by separator? ")
if mw.ustring.match(pn, "^" .. testProvinceEncoded .. "[^%
debugLog(nil, "Yes")
return testProvince
Line 286 ⟶ 290:
debugLog(4, "match at end, preceded by separator? ")
if mw.ustring.match(pn, "[^%
debugLog(nil, "Yes")
return testProvince
Line 293 ⟶ 297:
debugLog(4, "match anywhere, preceded and followed by separator? ")
if mw.ustring.match(pn, "[^%
debugLog(nil, "Yes")
return testProvince
Line 311 ⟶ 315:
local testProvinceStrippedEncoded = patternSearchEncode(testProvinceStripped)
debugLog(4, "test pattern without leading definite article, i.e. '" .. testProvinceStrippedEncoded .. "' ? ")
if (mw.ustring.match(pn, "[^%
or (mw.ustring.match(pn, "^" .. testProvinceStrippedEncoded .. "[^%
or (mw.ustring.match(pn, "[^%
or (mw.ustring.match(pn, "^" .. testProvinceStrippedEncoded .. "$") ~= nil) then
debugLog(nil, "Yes")
Line 337 ⟶ 341:
debugLog(2, "split pagename around [" .. validprovinceName .. "]")
local validProvinceEncoded = mw.ustring.gsub(validprovinceName, "([%W])", "%%%1")
title_prefix = match_prefix
title_suffix = match_suffix
debugLog(2, "parse successful")
debugLog(3, "title_prefix = [" .. title_prefix .. "]")
Line 423 ⟶ 429:
-- some error parsing the title, so don't proceed to output
local trackingCatInvalid = "[[Category:" .. templateName .. " on invalid category]]"
return makeErrorMsg('the name of this category does not include a valid
end
|