模块:字表调用:修订间差异
来自潮语辞书
更多操作
创建页面,内容为“local p = {} function p.getReading(frame) local char = frame.args[1] local region = frame.args[2] if not char or char == "" then return "错误:需要指定查询的字。" end if not region or region == "" then return "错误:需要指定地区。" end local ok, mod = pcall(require, "Module:调查字表/饶平-三饶片-" .. region) if not ok or not mod or not mod.data then return "查无此地区…” |
小 沙茶ちゃん移动页面模块:字表调用IPA至模块:字表调用 |
||
(没有差异)
|
2025年7月9日 (三) 17:34的版本
此模块的文档可以在模块:字表调用/doc创建
local p = {}
function p.getReading(frame)
local char = frame.args[1]
local region = frame.args[2]
if not char or char == "" then
return "错误:需要指定查询的字。"
end
if not region or region == "" then
return "错误:需要指定地区。"
end
local ok, mod = pcall(require, "Module:调查字表/饶平-三饶片-" .. region)
if not ok or not mod or not mod.data then
return "查无此地区数据。"
end
local readings = mod.data[char]
if not readings then
return "查无此字在" .. region .. "的读音。"
end
local result = {}
for _, entry in ipairs(readings) do
local s = entry["IPA"] or ""
local zt = entry["字态"] or ""
local note = entry["注释"] or ""
local is_gray = entry["灰色"]
if is_gray then
s = '<span style="color:gray">' .. s .. '</span>'
end
if zt ~= "" then
s = s .. '<span style="color:#fff;">[' .. zt .. ']</span>'
end
if note ~= "" then
s = s .. ' <sub>' .. mw.text.nowiki(note) .. '</sub>'
end
table.insert(result, '<div>' .. s .. '</div>')
end
return table.concat(result, "\n")
end
return p