モジュール:サンドボックス/本日晴天/test

モジュールの解説[作成]
require('strict')
local p = {}

function p.main(frame)
	local cs_module = frame.args.Module
	
	if not cs_module or cs_module == '' then
		cs_module = 'CS1'
	end
	
	local res_cs = require('Module:Citation/' .. cs_module).citation(frame)
	local res_t = {}
	
	for m in res_cs:gmatch('%<span class="cs1%-visible%-error.-%</span%>') do
		table.insert(res_t, m)
	end
	for m in res_cs:gmatch('%[%[Category:.-%]%]') do
		table.insert(res_t, m)
	end
	
	if not res_t[1] then
		return ''
	end
	
	local res = table.concat(res_t)
	local visible = frame.args.Visible
	
	if not visible or visible == '' then
		res = res:gsub('cs1%-visible%-error', 'cs1-hidden-error')
	end
	
	return frame:extensionTag ('templatestyles', '', {src='Module:Citation/CS1/styles.css'}) .. res
end

return p