Modul:Detect singular: Unterschied zwischen den Versionen

(count the number of list elements)
(an entry in a list should always be singular, also)
Zeile 21: Zeile 21:
end
end
s = tostring(s)
s = tostring(s)
s = mw.ustring.gsub(s,'%b[]','WIKILINK') -- replace all wikilinks with string
if plainFind(s,'forcedetectsingular') then -- magic data string to return true
if plainFind(s,'forcedetectsingular') then -- magic data string to return true
return true
return true
Zeile 28: Zeile 27:
return false
return false
end
end
-- replace all wikilinks with fixed string
s = mw.ustring.gsub(s,'%b[]','WIKILINK')
-- replace all list items with a fixed string
s, numListItems = mw.ustring.gsub(s,'<%s*li%s*>.-<%s*/li%s*>','<li>LISTITEM</li>')
local hasComma = checkComma and mw.ustring.find(s, '%a,%s')  
local hasComma = checkComma and mw.ustring.find(s, '%a,%s')  
local hasMultipleListElements = countMatches(s,'<%s*li') > 1
local hasMultipleListElements = numListItems > 1
local hasAnd = mw.ustring.find(s,'%Aand%A')
local hasAnd = mw.ustring.find(s,'%Aand%A')
local hasBreak = mw.ustring.find(s,'<%s*br')
local hasBreak = mw.ustring.find(s,'<%s*br')