跳至內容

「Module:ConvertLink」:修訂間差異

增加 407 位元組 、​ 2024年10月25日 (星期五)
尝试优化
無編輯摘要
(尝试优化)
 
行 112: 行 112:
end
end


local DL
local DL,CDL,SDL
local dInit,sdlInit
 
local function designerInit()
DL = mw.text.jsonDecode(mw.title.new('Template:DesignersList.json'):getContent())
CDL = DL.complex
SDL = DL.simple
dInit = true
end
 
local function SDL_Init()
table.sort(SDL,
function(a,b)
return #(a.display)<#(b.display)
end)
sdlInit = true
end
 
local function findDesigner(designerName, songid)
local function findDesigner(designerName, songid)
DL = DL or mw.loadJsonData 'Template:DesignersList.json'
if not dInit then designerInit() end
local CDL = DL.complex
local SDL = DL.simple
local theType = '谱师'
local theType = '谱师'
local function defaultSDL(text)
local function defaultSDL(text)
if not sdlInit then SDL_Init() end
local temp_text = text
local temp_text = text
local text_len = #text
local link_placeholders = {}
local link_placeholders = {}
local placeholder_count = 0
local placeholder_count = 0
行 131: 行 148:
link_placeholders[placeholder] = link_text
link_placeholders[placeholder] = link_text
temp_text = string.gsub(temp_text, dis, placeholder)
temp_text = string.gsub(temp_text, dis, placeholder)
text_len = text_len - #dis
placeholder_count = placeholder_count + 1
placeholder_count = placeholder_count + 1
if text_len < #dis then break end
end
end
-- temp_text = temp_text .. '__'..text_len
end
end
if placeholder_count == 0 then return text end
if placeholder_count == 0 then return text end
行 143: 行 163:
local designer
local designer
local theType = '谱师'
local designer_list = CDL[designerName]
local designer_list = CDL[designerName]
if designer_list then
if designer_list then
956

次編輯