Modul:Detect singular: Unterschied zwischen den Versionen

make it an option to rewrite the links
(args.bullets defaults to true)
(make it an option to rewrite the links)
Zeile 12: Zeile 12:
end
end


function p._main(args)
function p._main(origArgs)
local checkComma = not yesNo(args.no_comma,true)
local args = {}
if args.bullets == nil then
-- canonicalize boolean arguments
args.bullets = true
for key, default in pairs({no_comma=false,bullets=true,ignore_links=true}) do
if origArgs[key] then
args[key] = default
else
args[key] = yesNo(origArgs[key],default)
end
end
end
local checkBullets = yesNo(args.bullets,true)
local checkComma = not args.no_comma
local checkBullets = args.bullets
local rewriteLinks = args.ignore_links
local s = args[1]  -- the input string
local s = args[1]  -- the input string
if not s then
if not s then
Zeile 39: Zeile 46:
end
end
-- replace all wikilinks with fixed string
-- replace all wikilinks with fixed string
s = mw.ustring.gsub(s,'%b[]','WIKILINK')  
if rewriteLinks then
s = mw.ustring.gsub(s,'%b[]','WIKILINK')  
end
local hasComma = checkComma and mw.ustring.find(s, '[%a%s],[%a%s]')  
local hasComma = checkComma and mw.ustring.find(s, '[%a%s],[%a%s]')  
local hasAnd = mw.ustring.find(s,'[,%s]and%s')
local hasAnd = mw.ustring.find(s,'[,%s]and%s')
Anonymer Benutzer