Modulo:Delink/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
singolo link
use require('strict') instead of require('Module:No globals')
 
(4 versioni intermedie di un altro utente non mostrate)
Riga 6:
]]--
 
require('Module:No globalsstrict')
 
local p = {}
Riga 15:
return s
else
s =return s:match("%[%[|(.*)%]%]")
return args['singolo link'] and mw.text.trim(s) or s
end
end
Line 32 ⟶ 31:
end
 
if not args['singolo link'] then
s = mw.text.trim(s)
else
-- Next up, brackets and commas.
if s:match("%(.-%)$") then -- Brackets trump commas.
Line 91 ⟶ 88:
if result:match("|") then -- Find if we're dealing with a piped link.
local pattern = "^%[%[.-|(.+)%]%]"
if args['singolo link'] and args[2] == 'v' then
pattern = "^%[%[(.-)|.+%]%]"
if args.v then
pattern = "^%[%[(.-)|.+%]%]"
end
result = mw.text.trim(result:match(pattern))
else
result = result:match(pattern)
end
result = mw.text.trim(result:match(pattern))
-- Remove new lines from the display of multiline piped links,
-- where the pipe is before the first new line.
result = result:gsub("\n", "")
else
local patternresult = args['singolo link'] and result:match("^%[%[ *(.-) *%]%]" or "^%[%[(.-)%]%]"
result = result:match(pattern)
end
 
Line 140 ⟶ 132:
if mw.ustring.match(s_decoded, "%c") then
return s
else
return s_decoded
end
Line 157 ⟶ 149:
local result = ""
while s ~= '' do
returnif args['singolo link'] and mw.text.trim(s) or sthen
-- Replace text using one iteration of gsub.
s local m = mw.ustring.gsubmatch(s, pattern, delinkFunction, 1)
if args.vm then
local m2 = delinkFunction(m)
if m ~= m2 then
s result = mw.text.trim(sm2)
break
end
end
else
-- Replace text using one iteration of gsub.
s = mw.ustring.gsub(s, pattern, delinkFunction, 1)
end
-- Append the left-most character to the result string.
result = result .. mw.ustring.sub(s, 1, 1)
Line 168 ⟶ 171:
function p._main(frame_args)
args = frame_args
args[1] = '[[| Test ]]aa[[Test]]'
local text = args[1] or ""
if args.refs == "yes" or args.note == "sì" then
-- Remove any [[Help:Strip markers]] representing ref tags. In most situations
-- this is not a good idea - only use it if you know what you are doing!
text = mw.ustring.gsub(text, "UNIQ%w*%-ref%-%d*%-QINU", "")
end
if not (args.comments == "no" or args.commenti == "no") then
text = text:gsub("<!%-%-.-%-%->", "") -- Remove html comments.
end
if not (args.wikilinks == "no" or args.wikilink == "no") then
if args['singolo link'] then
text = mw.ustring.match(text, "^%[%[.-%]%]")
end
text = delinkLinkClass(text, "^%[%[.-%]%]", delinkWikilink) -- De-link wikilinks.
end
if not (args.urls == "no" or args.url == "no") then
text = delinkLinkClass(text, "^%[.-%]", delinkURL) -- De-link URLs.
end
if not (args.whitespace == "no" or args.spazi == "no") then
-- Replace single new lines with a single space, but leave double new lines
-- and new lines only containing spaces or tabs before a second new line.