Module:Str find word: Difference between revisions

Content deleted Content added
m Protected "Module:Str find word": High-risk template or module: 524 transclusions (more info) ([Edit=Require autoconfirmed or confirmed access] (indefinite))
Undid revision 1147915801 by Lemondoge (talk): oh dear. I checked with testcases - don't know how this goofed
 
(9 intermediate revisions by 2 users not shown)
Line 1:
--- STABLE: 16-11-2021 20:30
--- done 25-10-2022: cade=default false, A=/=a. (was:true A=a)
-- todo: sep = len 1 max?; return string has comma-space not just comma
-- ? not %escape then?
 
require('strict')
local p = {}
Line 87 ⟶ 82:
eSep = escape_word(tArgs.sep)
local patstring = '%f[^' .. eSep .. '][^' .. eSep .. ']+%f[' .. eSep .. ']'
if yesno(tArgs.explain, truefalse) then
report.xpMessage('1.eSep: ' .. eSep) -- dev
report.xpMessage('2.pattern: ' .. patstring) -- dev
Line 108 ⟶ 103:
end
 
-- Step 4: when read booleans, converse to words to true/false
-- todo: check parameter here not elsewhere
if tArgs.booleans then
if tArgs.booleans then -- TODO if Yesno(tArgs.booleans) ...
local sBool
for i, v in ipairs(wordTable) do
Line 167 ⟶ 163:
bAND = true
end
 
return bAND, tHits
end
Line 230 ⟶ 226:
-- explain=testcases => WHEN in ns: template: or user: AND subpage = '/testcases' THEN show permanently
local function checkExplain(tArgs)
return false -- never. 22Mar2023 checkExplain(newArgs)
if yesno(tArgs.explain, true) then
if yesno(tArgs.explain, false) == true then -- explicit True so preview show
if isPreview() == true then
return true
end
elseif tArgs.explain == 'testcases' then
local titleObj = mw.title.getCurrentTitle()
if titleObj:inNamespaces('template', 'user')
and titleObj.subpageText == 'testcases'
and titleObj.isSubpage then
return 'testcases'
end
end
end
return false
end
 
Line 278 ⟶ 260:
-- No words to check
resultALL = false
if yesno(tArgs.explain, truefalse) then
report.xpNoWords(tArgs, sourceWordTable, andWordTable, orWordTable)
end
Line 302 ⟶ 284:
end
if yesno(tArgs.explain, truefalse) then
if tArgs.yes ~= nil then
if (tArgs.yes == '') and (tArgs.no == '') then
Line 358 ⟶ 340:
newArgs['orString'] = decodeUnicode(origArgs['orw'] or origArgs['orwords'] or '')
-- boolean options: catch both parameters, also handle nil & nonsense input values:
newArgs['case'] = yesno(origArgs['case'] or origArgs['casesensitive'] or falsetrue, falsetrue) -- defaults to FalseTrue
newArgs['booleans'] = yesno(origArgs['bool'] or origArgs['booleans'] or false, false) -- defaults to False
newArgs['literals'] = yesno(origArgs['literals'] or origArgs['lit'] or true, true) -- defaults to True
newArgs['yes'] = origArgs['yes'] or nil -- nil; default so return sYeslist; keep '' as legal input & return value
newArgs['no'] = origArgs['no'] or ''
newArgs['explain'] = origArgs['explain']false or-- falsenever. 22Mar2023 checkExplain(newArgs)
 
newArgs.explain = false -- never. 22Mar2023 checkExplain(newArgs)
return newArgs
Line 376 ⟶ 358:
 
tArgs = parseArgs(origArgs)
if yesno(tArgs.explain, truefalse) then
initReport()
report.xpListArguments(origArgs)
Line 388 ⟶ 370:
end
 
if yesno(tArgs.explain, truefalse) then
return sReturn .. report.xpPresent(tArgs.explain)
else