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

个编辑