Module:Links: Difference between revisions

1,574 bytes removed ,  5 January 2022
no edit summary
(Created page with "local export = {} --[=[ Unsupported titles and pages with high memory usage are listed at Module:links/data. Other modules used: Module:script utilities...")
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 12: Line 12:
[[Module:utilities]]
[[Module:utilities]]
[[Module:string]]
[[Module:string]]
[[Module:debug]]
]=]
]=]


Line 64: Line 63:
if target:sub(1, 1) == "/" then
if target:sub(1, 1) == "/" then
return ":" .. target
return ":" .. target
-- Link to appendix for reconstructed terms and terms in appendix-only languages
elseif target:sub(1, 1) == "*" and #target > 1 then
if lang:getCode() == "und" then
return nil
end
target = "Reconstruction:" .. lang:getCanonicalName() .. "/" .. usub(target, 2)
elseif lang:getType() == "reconstructed" then
error("The specified language " .. lang:getCanonicalName()
.. " is unattested, while the given word is not marked with '*' to indicate that it is reconstructed")
elseif lang:getType() == "appendix-constructed" then
target = "Appendix:" .. lang:getCanonicalName() .. "/" .. target
end
end
Line 150: Line 136:
if not prefixes[prefix] then
if not prefixes[prefix] then
if link.fragment or link.target:find("#$") then
require("Module:debug").track {
"links/fragment",
"links/fragment/" .. lang:getCode()
}
end
if not link.fragment and lang:getCode() ~= "und" then
if not link.fragment and lang:getCode() ~= "und" then
Line 229: Line 209:
if data.alt then
if data.alt then
require("Module:debug").track("links/alt-ignored")
mw.log("(from Module:links)", "text with embedded wikilinks:", text,
mw.log("(from Module:links)", "text with embedded wikilinks:", text,
"ignored alt:", data.alt, "lang:", data.lang:getCode())
"ignored alt:", data.alt, "lang:", data.lang:getCode())
Line 235: Line 214:
if data.id then
if data.id then
require("Module:debug").track("links/id-ignored")
mw.log("(from Module:links)", "text with embedded wikilinks:", text,
mw.log("(from Module:links)", "text with embedded wikilinks:", text,
"ignored id:", data.id, "lang:", data.lang:getCode())
"ignored id:", data.id, "lang:", data.lang:getCode())
Line 244: Line 222:
-- There are no [ ] in between.
-- There are no [ ] in between.
-- This makes the wikilink tag redundant.
-- This makes the wikilink tag redundant.
if text:find("^%[%[[^%[%]]+%]%]$") then
if not text:find("^%[%[[^%[%]]+%]%]$") then
require("Module:debug").track("links/redundant wikilink")
else
local temp = text:gsub("^%[%[(.+)%]%]$", "%1")
local temp = text:gsub("^%[%[(.+)%]%]$", "%1")
temp = temp:gsub("%]%], %[%[", "|")
temp = temp:gsub("%]%], %[%[", "|")
if not temp:find("[%[%]]") then
require("Module:debug").track("links/list")
end
end
end
end
end
Line 401: Line 373:
-- Track uses of sc parameter
-- Track uses of sc parameter
local best = require("Module:scripts").findBestScript(data.alt or data.term, data.lang)
local best = require("Module:scripts").findBestScript(data.alt or data.term, data.lang)
require("Module:debug").track("links/sc")
if data.sc:getCode() == best:getCode() then
require("Module:debug").track("links/sc/redundant")
require("Module:debug").track("links/sc/redundant/" .. data.sc:getCode())
else
require("Module:debug").track("links/sc/needed")
require("Module:debug").track("links/sc/needed/" .. data.sc:getCode())
end
end
end
Line 435: Line 398:
else
else
accel = data.accel
accel = data.accel
require("Module:debug").track("links/accel not table")
require("Module:debug").track("links/accel not table/" .. data.lang:getCode())
end
end