Modulo:Delink: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
traduco parametri |
rimuovo carattere di controllo invisibile che provoca match anomali |
||
(2 versioni intermedie di uno stesso utente non sono mostrate) | |||
Riga 6:
]]--
require('
local p = {}
Riga 15:
return s
else
return args['singolo link'] and mw.text.trim(s) or s▼
end
end
Riga 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.
Riga 64 ⟶ 61:
end
-- Check for bad characters.
if mw.ustring.match(titlearea, "[%[%]<>{}%%
return s
end
Riga 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
if args[2] == 'v' then▼
▲ pattern = "^%[%[(.-)|.+%]%]"
end▼
result = mw.text.trim(result:match(pattern))▼
end
-- Remove new lines from the display of multiline piped links,
-- where the pipe is before the first new line.
result = result:gsub("\n", "")
else
end
Riga 140 ⟶ 132:
if mw.ustring.match(s_decoded, "%c") then
return s
else
return s_decoded
end
Riga 157 ⟶ 149:
local result = ""
while s ~= '' do
-- Replace text using one iteration of gsub.▼
if m then
local m2 = delinkFunction(m)
break
end
▲ end
▲ -- 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)
Riga 178 ⟶ 181:
end
if not (args.wikilinks == "no" or args.wikilink == "no") then
▲ end
text = delinkLinkClass(text, "^%[%[.-%]%]", delinkWikilink) -- De-link wikilinks.
end
|