Zum Inhalt springen

Modul:Detect singular: Unterschied zwischen den Versionen

always count bullets
(make semi-colon work)
(always count bullets)
Zeile 15: Zeile 15:
local args = {}
local args = {}
-- canonicalize boolean arguments
-- canonicalize boolean arguments
for key, default in pairs({no_comma=false,bullets=true,ignore_links=true}) do
for key, default in pairs({no_comma=false,ignore_links=true}) do
if origArgs[key] == nil then
if origArgs[key] == nil then
args[key] = default
args[key] = default
Zeile 23: Zeile 23:
end
end
local checkComma = not args.no_comma
local checkComma = not args.no_comma
local checkBullets = args.bullets
local rewriteLinks = args.ignore_links
local rewriteLinks = args.ignore_links
local s = origArgs[1]  -- the input string
local s = origArgs[1]  -- the input string
Zeile 52: Zeile 51:
local hasAnd = mw.ustring.find(s,'[,%s]and%s')
local hasAnd = mw.ustring.find(s,'[,%s]and%s')
local hasBreak = mw.ustring.find(s,'<%s*br')
local hasBreak = mw.ustring.find(s,'<%s*br')
local hasBullets = checkBullets and countMatches(s,'%*+') > 1
local hasBullets = countMatches(s,'%*+') > 1
local multipleQids = mw.ustring.find(s,'Q%d+[%p%s]+Q%d+') -- has multiple QIDs in a row
local multipleQids = mw.ustring.find(s,'Q%d+[%p%s]+Q%d+') -- has multiple QIDs in a row
return not (hasComma or hasAnd or hasBreak or hasBullets or multipleQids)
return not (hasComma or hasAnd or hasBreak or hasBullets or multipleQids)
Anonymer Benutzer