Module:Sandbox/LVL: Difference between revisionsGive feedback
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 7: | Line 7: | ||
-- Load icon data and language codes | -- Load icon data and language codes | ||
local iconData = require("Module:Icon/data") | local iconData = require("Module:Icon/data") | ||
local nameToNum = {} | |||
do | |||
local raw = mw.title.getCurrentTitle():getContent() or '' | |||
for num, name in raw:gmatch('<span class="abi%-num" data%-num="(%d)"></span>([^<]+)') do | |||
nameToNum[name:gsub('^%s*',''):gsub('%s*$',''):lower()] = tonumber(num) | |||
end | |||
end | |||
local lang_codes = mw.loadJsonData("Data:LangCodes.json") | local lang_codes = mw.loadJsonData("Data:LangCodes.json") | ||
| Line 81: | Line 88: | ||
-- build hero-page fragment automatically | -- build hero-page fragment automatically | ||
local num = nameToNum[displayName:lower()] | |||
local frag = num and ("("..num..")_"..toAnchor(displayName)) | |||
or toAnchor(displayName) | |||
local link | local link | ||
if baseLink ~= "" and not baseLink:find("#", 1, true) then | if baseLink ~= "" and not baseLink:find("#", 1, true) then | ||
link = baseLink .. "#" .. | link = baseLink .. "#" .. frag | ||
else | else | ||
link = baseLink | link = baseLink | ||