Modul:Detect singular: Unterschied zwischen den Versionen

K (Protected "Module:Detect singular": High-risk template or module: 18344 transclusions (more info) ([Edit=Require template editor access] (indefinite) [Move=Require template editor access] (indefinite)))
(remove wikimarkup before performing last 4 plural tests)
Zeile 2: Zeile 2:
local getArgs = require('Module:Arguments').getArgs
local getArgs = require('Module:Arguments').getArgs
local yesNo = require('Module:Yesno')
local yesNo = require('Module:Yesno')
local getPlain = require('Module:Text').Text().getPlain


-- function to determine whether "sub" occurs in "s"
-- function to determine whether "sub" occurs in "s"
Zeile 57: Zeile 58:
end
end
-- Five conditions: any one of them can make the string a plural
-- Five conditions: any one of them can make the string a plural
local hasBreak = mw.ustring.find(s,'<%s*br')
-- For the last 4, evaluate on string stripped of wikimarkup
s = getPlain(s)
local hasComma = checkComma and mw.ustring.find(s, '%D[,;]%D') -- semi-colon similar to comma
local hasComma = checkComma and mw.ustring.find(s, '%D[,;]%D') -- semi-colon similar to comma
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 hasBullets = 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