モジュール:ParenToKagi
ナビゲーションに移動
検索に移動
-- Module:ParenToKagi
-- 全角丸括弧(())をかぎ括弧〈〉に変換するモジュール
local p = {}
-- 文字列中の全角丸括弧を変換
local function replace_paren(text)
if not text then return '' end
-- 丸括弧で囲まれたもの → 〈内容〉
text = text:gsub('((.-))', '〈%1〉')
-- 開き丸括弧だけ → 〈
text = text:gsub('(', '〈')
-- 閉じ丸括弧だけ → 〉
text = text:gsub(')', '〉')
return text
end
function p.convert(frame)
local input = frame.args[1] or frame.args['1'] or ''
return replace_paren(input)
end
return p