モジュール:Trim quotes

提供:Wikiminati
2019年5月21日 (火) 10:19時点におけるTemplate:Cquote>Johnuniqによる版 (mw.ustring is not needed to find apostrophe/quote; this is more efficient)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)

このモジュールについての説明文ページを モジュール:Trim quotes/doc に作成できます

local p = {}

function p._trim(s)
	if s then
		if s:match([[^(['"]).*%1$]]) then return p._trim(string.sub(s,2,-2)) else return s end
	else
		return ""
	end
end

function p.trim(frame)
	local s = (frame.args['s'] or frame.args[1]) or (frame:getParent().args['s'] or frame:getParent().args[1])
	return p._trim(s)
end

return p