「モジュール:Zh」の版間の差分
表示
削除された内容 追加された内容
編集の要約なし |
一部のページでスクリプトエラーが発生していたのを修正 |
||
(同じ利用者による、間の1版が非表示) | |||
5行目: | 5行目: | ||
-- articles in which traditional Chinese preceeds simplified Chinese |
-- articles in which traditional Chinese preceeds simplified Chinese |
||
local t1st = { |
local t1st = { |
||
--["228 Incident"] = true, |
|||
--["Chinese calendar"] = true, |
|||
--["Lippo Centre, Hong Kong"] = true, |
|||
--["Republic of China"] = true, |
|||
--["Republic of China at the 1924 Summer Olympics"] = true, |
|||
--["Taiwan"] = true, |
|||
--["Taiwan (island)"] = true, |
|||
--["Taiwan Province"] = true, |
|||
--["Wei Boyang"] = true, |
|||
} |
} |
||
12行目: | 21行目: | ||
["cs"] = "中", |
["cs"] = "中", |
||
["s"] = "簡体字", |
["s"] = "簡体字", |
||
["ss"] = "簡", |
|||
["t"] = "繁体字", |
["t"] = "繁体字", |
||
["ts"] = "繁", |
|||
["p"] = "拼音", |
["p"] = "拼音", |
||
["ps"] = "拼", |
["ps"] = "拼", |
||
23行目: | 32行目: | ||
["sl"] = "シドニー・ラウ式", |
["sl"] = "シドニー・ラウ式", |
||
["poj"] = "白話字", |
["poj"] = "白話字", |
||
["tl"] = "台羅", |
|||
["zhu"] = "注音", |
["zhu"] = "注音", |
||
["zs"] = "注", |
["zs"] = "注", |
||
["l"] = "英文 |
["l"] = "英文直訳", |
||
["tr"] = "翻訳", |
|||
} |
} |
||
31行目: | 42行目: | ||
local wlinks = { |
local wlinks = { |
||
["c"] = "中国語", |
["c"] = "中国語", |
||
["cs"] = "中国語", |
|||
["s"] = "簡体字", |
["s"] = "簡体字", |
||
["ss"] = "簡体字", |
|||
["t"] = "繁体字", |
["t"] = "繁体字", |
||
["ts"] = "繁体字", |
|||
["p"] = "拼音", |
["p"] = "拼音", |
||
["ps"] = "拼音", |
|||
["tp"] = "通用拼音", |
["tp"] = "通用拼音", |
||
["w"] = "ウェード式", |
["w"] = "ウェード式", |
||
44行目: | 51行目: | ||
["sl"] = "シドニー・ラウ式ローマ字", |
["sl"] = "シドニー・ラウ式ローマ字", |
||
["poj"] = "白話字", |
["poj"] = "白話字", |
||
["tl"] = "台湾語ローマ字方案", |
|||
["zhu"] = "注音符号", |
["zhu"] = "注音符号", |
||
[" |
--["l"] = "Literal translation", |
||
--["tr"] = "Translation", |
|||
} |
} |
||
wlinks["cs"], wlinks["ss"], wlinks["ts"], wlinks["ps"], wlinks["zs"] = wlinks["c"], wlinks["s"], wlinks["t"], wlinks["p"], wlinks["zhu"] |
|||
-- for those parts which are to be treated as languages their ISO code |
-- for those parts which are to be treated as languages their ISO code |
||
local ISOlang = { |
local ISOlang = { |
||
["c"] = "zh", |
["c"] = "zh", |
||
["cs"] = "zh", |
|||
["t"] = "zh-Hant", |
["t"] = "zh-Hant", |
||
["ts"] = "zh-Hant", |
|||
["s"] = "zh-Hans", |
["s"] = "zh-Hans", |
||
[" |
["p"] = "zh-Latn", |
||
[" |
["tp"] = "zh-Latn-tongyong", |
||
["ps"] = "zh-Latn-pinyin", |
|||
["tp"] = "zh-Latn", |
|||
["w"] = "zh-Latn-wadegile", |
["w"] = "zh-Latn-wadegile", |
||
["j"] = "yue-jyutping", |
["j"] = "yue-Latn-jyutping", |
||
["cy"] = "yue", |
["cy"] = "yue-Latn", |
||
["sl"] = "yue", |
["sl"] = "yue-Latn", |
||
["poj"] = "nan", |
["poj"] = "nan-Latn", |
||
["tl"] = "nan-Latn-tailo", |
|||
["zhu"] = "zh-Bopo", |
["zhu"] = "zh-Bopo", |
||
["zs"] = "zh-Bopo", |
|||
} |
} |
||
ISOlang["cs"], ISOlang["ss"], ISOlang["ts"], ISOlang["ps"], ISOlang["zs"] = ISOlang["c"], ISOlang["s"], ISOlang["t"], ISOlang["p"], ISOlang["zhu"] |
|||
local italic = { |
local italic = { |
||
["p"] = false, |
|||
["tp"] = false, |
|||
["w"] = true, |
["w"] = true, |
||
["j"] = true, |
["j"] = true, |
||
74行目: | 83行目: | ||
["sl"] = true, |
["sl"] = true, |
||
["poj"] = true, |
["poj"] = true, |
||
["tl"] = true, |
|||
} |
} |
||
80行目: | 90行目: | ||
["sl"] = true, |
["sl"] = true, |
||
} |
} |
||
-- Categories for different kinds of Chinese text |
-- Categories for different kinds of Chinese text |
||
local cats = { |
local cats = { |
||
["c"] = "", --[[Category:Articles containing Chinese-language text]] |
|||
["c"] = "", |
|||
["s"] = "", --[[Category:Articles containing simplified Chinese-language text]] |
|||
["s"] = "", |
|||
["t"] = "", --[[Category:Articles containing traditional Chinese-language text]] |
|||
["t"] = "", |
|||
} |
} |
||
--cats["cs"], cats["ss"], cats["ts"] = cats["c"], cats["s"], cats["t"] |
|||
function p.Zh(frame) |
function p.Zh(frame) |
||
96行目: | 108行目: | ||
function p._Zh(args) |
function p._Zh(args) |
||
if args["link"] then args["links"] = args["link"]; end |
|||
if args["label"] then args["labels"] = args["label"]; end |
|||
local uselinks = args["links"] ~= "no" -- whether to add links |
|||
local uselabels = args["labels"] ~= "no" -- whether to have labels |
|||
local capfirst = args["scase"] ~= nil |
local capfirst = args["scase"] ~= nil |
||
local out = nil -- which term to put before the brackets |
|||
local usebrackets = 0 -- whether to have bracketed terms |
|||
local numargs = 0 |
|||
if args["out"] then |
|||
out = args["out"] |
|||
usebrackets = 1 |
|||
end |
|||
local t1 = false -- whether traditional Chinese characters go first |
local t1 = false -- whether traditional Chinese characters go first |
||
local j1 = false -- whether Cantonese Romanisations go first |
local j1 = false -- whether Cantonese Romanisations go first |
||
local poj1 = false -- whether Hokkien Romanisations go first |
|||
local testChar |
local testChar |
||
if (args["first"]) then |
if (args["first"]) then |
||
107行目: | 131行目: | ||
if (testChar == "t") then |
if (testChar == "t") then |
||
t1 = true |
t1 = true |
||
end |
|||
if (testChar == "j") then |
if (testChar == "j") then |
||
j1 = true |
j1 = true |
||
end |
|||
if (testChar == "poj") then |
|||
poj1 = true |
|||
end |
|||
end |
end |
||
end |
end |
||
119行目: | 146行目: | ||
-- based on setting/preference specify order |
-- based on setting/preference specify order |
||
local orderlist = {"c", "cs", "s", "ss", "t", "ts", "p", "ps", "tp", "w", "j", "cy", "sl", "poj", "zhu", "zs", "l"} |
local orderlist = {"c", "cs", "s", "ss", "t", "ts", "p", "ps", "tp", "w", "j", "cy", "sl", "poj", "tl", "zhu", "zs", "l", "tr"} |
||
if (t1) then |
if (t1) then |
||
orderlist[ |
orderlist[3] = "t" |
||
orderlist[ |
orderlist[4] = "ts" |
||
orderlist[5] = "s" |
|||
orderlist[6] = "ss" |
|||
end |
end |
||
if (j1) then |
if (j1) then |
||
orderlist[ |
orderlist[7] = "j" |
||
orderlist[ |
orderlist[8] = "cy" |
||
orderlist[ |
orderlist[9] = "sl" |
||
orderlist[ |
orderlist[10] = "p" |
||
orderlist[ |
orderlist[11] = "ps" |
||
orderlist[ |
orderlist[12] = "tp" |
||
orderlist[13] = "w" |
|||
end |
end |
||
if (poj1) then |
|||
orderlist[7] = "poj" |
|||
orderlist[8] = "tl" |
|||
orderlist[9] = "p" |
|||
orderlist[10] = "ps" |
|||
orderlist[11] = "tp" |
|||
orderlist[12] = "w" |
|||
orderlist[13] = "j" |
|||
orderlist[14] = "cy" |
|||
orderlist[15] = "sl" |
|||
end |
|||
-- rename rules. Rules to change parameters and labels based on other parameters |
-- rename rules. Rules to change parameters and labels based on other parameters |
||
if args["hp"] then |
if args["hp"] then |
||
148行目: | 189行目: | ||
args["s"] = nil |
args["s"] = nil |
||
args["t"] = nil |
args["t"] = nil |
||
if out == "s" or out == "t" then |
|||
out = "c" |
|||
end |
|||
--elseif (not (args["s"] and args["t"])) then |
|||
-- use short label if only one of simplified and traditional |
-- use short label if only one of simplified and traditional |
||
-- labels["s"] = labels["c"] |
-- labels["s"] = labels["c"] |
||
-- labels["t"] = labels["c"] |
-- labels["t"] = labels["c"] |
||
end |
end |
||
if (args["ss"] and args["ss"] == args["ts"]) then |
|||
-- Treat simplified + traditional as Chinese if they're the same |
|||
args["cs"] = args["ss"] |
|||
args["ss"] = nil |
|||
args["ts"] = nil |
|||
if out == "ss" or out == "ts" then |
|||
out = "cs" |
|||
end |
|||
--elseif (not (args["ss"] and args["ts"])) then |
|||
-- use short label if only one of simplified and traditional |
|||
-- labels["ss"] = labels["cs"] |
|||
-- labels["ts"] = labels["cs"] |
|||
end |
|||
if out then |
|||
for i, v in ipairs (orderlist) do -- shift `out` to the beginning of the order list |
|||
if v == out then |
|||
table.remove(orderlist, i) |
|||
table.insert(orderlist, 1, v) |
|||
break |
|||
end |
|||
end |
|||
end |
|||
if (out == "c" and args["s"]) then usebrackets = 2; end |
|||
if (out == "cs" and args["ss"]) then usebrackets = 3; end |
|||
local body = "" -- the output string |
local body = "" -- the output string |
||
162行目: | 231行目: | ||
for i, part in ipairs(orderlist) do |
for i, part in ipairs(orderlist) do |
||
if (args[part]) then |
if (args[part]) then |
||
numargs = numargs + 1 |
|||
-- build label |
-- build label |
||
label = "" |
label = "" |
||
170行目: | 240行目: | ||
capfirst = false |
capfirst = false |
||
end |
end |
||
if (uselinks and part ~= "l") then |
if (uselinks and part ~= "l" and part ~= "tr") then |
||
label = "[[" .. wlinks[part] .. "|" .. label .. "]]" |
label = "[[" .. wlinks[part] .. "|" .. label .. "]]" |
||
end |
end |
||
--if (part == "l" or part == "tr") then |
|||
-- label = "<abbr title=\"" .. wlinks[part] .. "\"><small>" .. label .. "</small></abbr>" |
|||
--else |
|||
label = label .. ":" |
|||
--end |
|||
label = label .. " " |
|||
end |
end |
||
-- build value |
-- build value |
||
183行目: | 258行目: | ||
if (ISOlang[part]) then |
if (ISOlang[part]) then |
||
-- add span for language if needed |
-- add span for language if needed |
||
params = {[" |
params = {["lang"] = ISOlang[part]} |
||
val = mw.text.tag({name="span",attrs=params, content=val}) |
val = mw.text.tag({name="span",attrs=params, content=val}) |
||
elseif (part == "l") then |
elseif (part == "l") then |
||
local terms = "" |
|||
-- put individual, potentially comma-separated glosses in single quotes |
|||
val = '"' .. val .. '"' |
|||
-- (first strip leading and trailing whitespace and quotes, including bold/italic markup) |
|||
for term in val:gmatch("[^;,]+") do |
|||
term = mw.text.trim(term, "%s\"'") |
|||
terms = terms .. "'" .. term .. "', " |
|||
end |
|||
val = string.sub(terms, 1, -3) |
|||
elseif (part == "tr") then |
|||
-- put translations in double quotes |
|||
-- (first strip leading and trailing spaces and quotes, including bold/italic markup) |
|||
val = mw.text.trim(val, "%s\"'") |
|||
val = """ .. val .. """ |
|||
end |
end |
||
if (italic[part]) then |
if (italic[part]) then |
||
193行目: | 279行目: | ||
val = "<i>" .. val .. "</i>" |
val = "<i>" .. val .. "</i>" |
||
end |
end |
||
if string.match(val, "</?sup>") then val = val.."" end |
--if string.match(val, "</?sup>") then val = val.."[[Category:Pages using template Zh with sup tags]]" end |
||
if (superscript[part]) then |
if (superscript[part]) then |
||
-- superscript |
-- superscript |
||
199行目: | 285行目: | ||
end |
end |
||
-- add both to body |
-- add both to body |
||
if numargs == usebrackets then |
|||
body = body .. label .. val .. "; " |
|||
-- opening bracket after the `out` term |
|||
body = body .. label .. val .. "(" |
|||
else |
|||
body = body .. label .. val .. "; " |
|||
end |
|||
end |
end |
||
end |
end |
||
if (body > "") then -- check for empty string |
if (body > "") then -- check for empty string |
||
if mw.ustring.sub(body, -1, -1) == '(' then |
|||
body = mw.ustring.sub(body, 1, -2) -- 末尾の開き括弧を除去 |
|||
else |
|||
body = string.sub(body, 1, -3) -- chop off final semicolon and space |
|||
end |
|||
if out and numargs > usebrackets then |
|||
-- closing bracket after the rest of the terms |
|||
body = body .. ")" |
|||
end |
|||
return body |
|||
else --no named parameters; see if there's a first parameter, ignoring its name |
else --no named parameters; see if there's a first parameter, ignoring its name |
||
if (args[1]) then |
if (args[1]) then |
||
214行目: | 314行目: | ||
label = "[[" .. wlinks["c"] .. "|" .. label .. "]]" |
label = "[[" .. wlinks["c"] .. "|" .. label .. "]]" |
||
end |
end |
||
label = label .. "& |
label = label .. ": " |
||
end |
end |
||
-- default to show links and labels as no options given |
-- default to show links and labels as no options given |
||
223行目: | 323行目: | ||
val = args[1] |
val = args[1] |
||
end |
end |
||
params = {[" |
params = {["lang"] = ISOlang["c"]} |
||
val = mw.text.tag({name="span",attrs=params, content=val}) |
val = mw.text.tag({name="span",attrs=params, content=val}) |
||
return label .. val |
return label .. val |
2025年1月5日 (日) 12:09時点における最新版
Luaモジュールを使用しています: |
このモジュールは{{Lang-zh}}を実装しています。主な機能はテンプレートの説明文で詳しく説明されていますので、記事における使用法についてはそちらをご参照ください。この説明文ではモジュールの機能について説明します。
モジュールの最初にあるtlstテーブルは繁体字が先に表示されるページを指定しており、随時追加されます(ページ名は順不同)。追加に先だって、このモジュールのノートページで提案してください。
使い方
ほかのモジュールから使う
このモジュールはテンプレートから呼び出すほか、モジュールから直接呼び出すこともできます。その場合、まずは下記のようにモジュールをロードしてください。
local Zh = require("Module:Zh")._Zh
続いて、下記のように引数をテーブルに記述して呼び出してください。
local output = Zh{["c"] = "中国", ["p"] = "zhōngguó"}
require('strict')
local p = {}
-- articles in which traditional Chinese preceeds simplified Chinese
local t1st = {
--["228 Incident"] = true,
--["Chinese calendar"] = true,
--["Lippo Centre, Hong Kong"] = true,
--["Republic of China"] = true,
--["Republic of China at the 1924 Summer Olympics"] = true,
--["Taiwan"] = true,
--["Taiwan (island)"] = true,
--["Taiwan Province"] = true,
--["Wei Boyang"] = true,
}
-- the labels for each part
local labels = {
["c"] = "中国語",
["cs"] = "中",
["s"] = "簡体字",
["ss"] = "簡",
["t"] = "繁体字",
["ts"] = "繁",
["p"] = "拼音",
["ps"] = "拼",
["tp"] = "通用拼音",
["w"] = "ウェード式",
["j"] = "粤拼",
["cy"] = "イェール式広東語",
["sl"] = "シドニー・ラウ式",
["poj"] = "白話字",
["tl"] = "台羅",
["zhu"] = "注音",
["zs"] = "注",
["l"] = "英文直訳",
["tr"] = "翻訳",
}
-- article titles for wikilinks for each part
local wlinks = {
["c"] = "中国語",
["s"] = "簡体字",
["t"] = "繁体字",
["p"] = "拼音",
["tp"] = "通用拼音",
["w"] = "ウェード式",
["j"] = "香港語言学学会粤語拼音方案",
["cy"] = "イェール式#広東語",
["sl"] = "シドニー・ラウ式ローマ字",
["poj"] = "白話字",
["tl"] = "台湾語ローマ字方案",
["zhu"] = "注音符号",
--["l"] = "Literal translation",
--["tr"] = "Translation",
}
wlinks["cs"], wlinks["ss"], wlinks["ts"], wlinks["ps"], wlinks["zs"] = wlinks["c"], wlinks["s"], wlinks["t"], wlinks["p"], wlinks["zhu"]
-- for those parts which are to be treated as languages their ISO code
local ISOlang = {
["c"] = "zh",
["t"] = "zh-Hant",
["s"] = "zh-Hans",
["p"] = "zh-Latn",
["tp"] = "zh-Latn-tongyong",
["w"] = "zh-Latn-wadegile",
["j"] = "yue-Latn-jyutping",
["cy"] = "yue-Latn",
["sl"] = "yue-Latn",
["poj"] = "nan-Latn",
["tl"] = "nan-Latn-tailo",
["zhu"] = "zh-Bopo",
}
ISOlang["cs"], ISOlang["ss"], ISOlang["ts"], ISOlang["ps"], ISOlang["zs"] = ISOlang["c"], ISOlang["s"], ISOlang["t"], ISOlang["p"], ISOlang["zhu"]
local italic = {
["p"] = false,
["tp"] = false,
["w"] = true,
["j"] = true,
["cy"] = true,
["sl"] = true,
["poj"] = true,
["tl"] = true,
}
local superscript = {
["w"] = true,
["sl"] = true,
}
-- Categories for different kinds of Chinese text
local cats = {
["c"] = "", --[[Category:Articles containing Chinese-language text]]
["s"] = "", --[[Category:Articles containing simplified Chinese-language text]]
["t"] = "", --[[Category:Articles containing traditional Chinese-language text]]
}
--cats["cs"], cats["ss"], cats["ts"] = cats["c"], cats["s"], cats["t"]
function p.Zh(frame)
-- load arguments module to simplify handling of args
local getArgs = require('Module:Arguments').getArgs
local args = getArgs(frame)
return p._Zh(args)
end
function p._Zh(args)
if args["link"] then args["links"] = args["link"]; end
if args["label"] then args["labels"] = args["label"]; end
local uselinks = args["links"] ~= "no" -- whether to add links
local uselabels = args["labels"] ~= "no" -- whether to have labels
local capfirst = args["scase"] ~= nil
local out = nil -- which term to put before the brackets
local usebrackets = 0 -- whether to have bracketed terms
local numargs = 0
if args["out"] then
out = args["out"]
usebrackets = 1
end
local t1 = false -- whether traditional Chinese characters go first
local j1 = false -- whether Cantonese Romanisations go first
local poj1 = false -- whether Hokkien Romanisations go first
local testChar
if (args["first"]) then
for testChar in mw.ustring.gmatch(args["first"], "%a+") do
if (testChar == "t") then
t1 = true
end
if (testChar == "j") then
j1 = true
end
if (testChar == "poj") then
poj1 = true
end
end
end
if (t1 == false) then
local title = mw.title.getCurrentTitle()
t1 = t1st[title.text] == true
end
-- based on setting/preference specify order
local orderlist = {"c", "cs", "s", "ss", "t", "ts", "p", "ps", "tp", "w", "j", "cy", "sl", "poj", "tl", "zhu", "zs", "l", "tr"}
if (t1) then
orderlist[3] = "t"
orderlist[4] = "ts"
orderlist[5] = "s"
orderlist[6] = "ss"
end
if (j1) then
orderlist[7] = "j"
orderlist[8] = "cy"
orderlist[9] = "sl"
orderlist[10] = "p"
orderlist[11] = "ps"
orderlist[12] = "tp"
orderlist[13] = "w"
end
if (poj1) then
orderlist[7] = "poj"
orderlist[8] = "tl"
orderlist[9] = "p"
orderlist[10] = "ps"
orderlist[11] = "tp"
orderlist[12] = "w"
orderlist[13] = "j"
orderlist[14] = "cy"
orderlist[15] = "sl"
end
-- rename rules. Rules to change parameters and labels based on other parameters
if args["hp"] then
-- hp an alias for p ([hanyu] pinyin)
args["p"] = args["hp"]
end
if args["tp"] then
-- if also Tongyu pinyin use full name for Hanyu pinyin
labels["p"] = "漢語拼音"
end
if (args["s"] and args["s"] == args["t"]) then
-- Treat simplified + traditional as Chinese if they're the same
args["c"] = args["s"]
args["s"] = nil
args["t"] = nil
if out == "s" or out == "t" then
out = "c"
end
--elseif (not (args["s"] and args["t"])) then
-- use short label if only one of simplified and traditional
-- labels["s"] = labels["c"]
-- labels["t"] = labels["c"]
end
if (args["ss"] and args["ss"] == args["ts"]) then
-- Treat simplified + traditional as Chinese if they're the same
args["cs"] = args["ss"]
args["ss"] = nil
args["ts"] = nil
if out == "ss" or out == "ts" then
out = "cs"
end
--elseif (not (args["ss"] and args["ts"])) then
-- use short label if only one of simplified and traditional
-- labels["ss"] = labels["cs"]
-- labels["ts"] = labels["cs"]
end
if out then
for i, v in ipairs (orderlist) do -- shift `out` to the beginning of the order list
if v == out then
table.remove(orderlist, i)
table.insert(orderlist, 1, v)
break
end
end
end
if (out == "c" and args["s"]) then usebrackets = 2; end
if (out == "cs" and args["ss"]) then usebrackets = 3; end
local body = "" -- the output string
local params -- for creating HTML spans
local label -- the label, i.e. the bit preceeding the supplied text
local val -- the supplied text
-- go through all possible fields in loop, adding them to the output
for i, part in ipairs(orderlist) do
if (args[part]) then
numargs = numargs + 1
-- build label
label = ""
if (uselabels) then
label = labels[part]
if (capfirst) then
label = mw.language.getContentLanguage():ucfirst(label)
capfirst = false
end
if (uselinks and part ~= "l" and part ~= "tr") then
label = "[[" .. wlinks[part] .. "|" .. label .. "]]"
end
--if (part == "l" or part == "tr") then
-- label = "<abbr title=\"" .. wlinks[part] .. "\"><small>" .. label .. "</small></abbr>"
--else
label = label .. ":"
--end
label = label .. " "
end
-- build value
val = args[part]
if (cats[part]) and mw.title.getCurrentTitle().namespace == 0 then
-- if has associated category AND current page in article namespace, add category
val = cats[part] .. val
end
if (ISOlang[part]) then
-- add span for language if needed
params = {["lang"] = ISOlang[part]}
val = mw.text.tag({name="span",attrs=params, content=val})
elseif (part == "l") then
local terms = ""
-- put individual, potentially comma-separated glosses in single quotes
-- (first strip leading and trailing whitespace and quotes, including bold/italic markup)
for term in val:gmatch("[^;,]+") do
term = mw.text.trim(term, "%s\"'")
terms = terms .. "'" .. term .. "', "
end
val = string.sub(terms, 1, -3)
elseif (part == "tr") then
-- put translations in double quotes
-- (first strip leading and trailing spaces and quotes, including bold/italic markup)
val = mw.text.trim(val, "%s\"'")
val = """ .. val .. """
end
if (italic[part]) then
-- italicise
val = "<i>" .. val .. "</i>"
end
--if string.match(val, "</?sup>") then val = val.."[[Category:Pages using template Zh with sup tags]]" end
if (superscript[part]) then
-- superscript
val = val:gsub("(%d)", "<sup>%1</sup>"):gsub("(%d)</sup>%*<sup>(%d)", "%1*%2"):gsub("<sup><sup>([%d%*]+)</sup></sup>", "<sup>%1</sup>")
end
-- add both to body
if numargs == usebrackets then
-- opening bracket after the `out` term
body = body .. label .. val .. "("
else
body = body .. label .. val .. "; "
end
end
end
if (body > "") then -- check for empty string
if mw.ustring.sub(body, -1, -1) == '(' then
body = mw.ustring.sub(body, 1, -2) -- 末尾の開き括弧を除去
else
body = string.sub(body, 1, -3) -- chop off final semicolon and space
end
if out and numargs > usebrackets then
-- closing bracket after the rest of the terms
body = body .. ")"
end
return body
else --no named parameters; see if there's a first parameter, ignoring its name
if (args[1]) then
-- if there is treat it as Chinese
label = ""
if (uselabels) then
label = labels["c"]
if (uselinks) then
label = "[[" .. wlinks["c"] .. "|" .. label .. "]]"
end
label = label .. ": "
end
-- default to show links and labels as no options given
if mw.title.getCurrentTitle().namespace == 0 then
-- if current page in article namespace
val = cats["c"] .. args[1]
else
val = args[1]
end
params = {["lang"] = ISOlang["c"]}
val = mw.text.tag({name="span",attrs=params, content=val})
return label .. val
end
return ""
end
end
return p