Module:曲师列表:修订间差异

Admin​(留言 | 贡献)
改用 模块:署名解析 的共用解析器
Admin​(留言 | 贡献)
输出加 __NOCONTENTCONVERT__/__NOTITLECONVERT__:署名与曲名保持 UTF-8 原字,不做繁简变体转换(无需给名字加包裹,无 DOM 开销)
 
(未显示同一用户的1个中间版本)
第16行: 第16行:
local parse = require('模块:署名解析')
local parse = require('模块:署名解析')
local norm = parse.norm
local norm = parse.norm
-- ===== 工具 =====
local function esc(s)
return (tostring(s or ''):gsub('|', '|'))
end
-- 链接目标: # 是 MediaWiki 的锚点分隔符, 标题里一律换成全角 #
-- 优先用「链接名」字段; 没有就回退到曲名并自动替换 (与 模块:曲目列表 保持一致)
local function pageName(song, suffix)
local n = song['链接名'] or song['曲名']
if suffix then
n = n .. '(' .. suffix .. ')'
end
return (n:gsub('#', '#'))
end
-- 排序分组: 0=符号/数字 1=拉丁 2=假名 3=汉字 4=其他
local function groupRank(name)
local cp = mw.ustring.codepoint(name, 1, 1)
if not cp then return 9 end
if (cp >= 0x30 and cp <= 0x39) or cp < 0x30 then return 0 end
if (cp >= 0x41 and cp <= 0x5A) or (cp >= 0x61 and cp <= 0x7A) then return 1 end
if (cp >= 0x3040 and cp <= 0x30FF) then return 2 end
if (cp >= 0x3400 and cp <= 0x9FFF) then return 3 end
return 4
end
local function langWrap(song)
local lang = song['lang']
if lang == 'ja' then
return '{{lang|ja|' .. esc(song['曲名']) .. '}}'
elseif lang == 'zh-Hant' then
return '{{lang|zh-Hant|' .. esc(song['曲名']) .. '}}'
end
return esc(song['曲名'])
end


local function loadJson(title)
local function loadJson(title)
第132行: 第169行:
table.insert(out, '|}')
table.insert(out, '|}')
if emitted == 0 then return '<span class="error">没有达到门槛(' .. minN .. ')的曲师</span>' end
if emitted == 0 then return '<span class="error">没有达到门槛(' .. minN .. ')的曲师</span>' end
return frame:preprocess(table.concat(out, '\n'))
return frame:preprocess('__NOCONTENTCONVERT__\n__NOTITLECONVERT__\n' .. table.concat(out, '\n'))
end
end


第233行: 第270行:


table.insert(out, '\n[[Category:曲师]]')
table.insert(out, '\n[[Category:曲师]]')
return frame:preprocess(table.concat(out, '\n'))
return frame:preprocess('__NOCONTENTCONVERT__\n__NOTITLECONVERT__\n' .. table.concat(out, '\n'))
end
end


return p
return p