Module:Sandbox/CAS222222221/S

This is an old revision of this page, as edited by 風中的刀劍 (talk | contribs) at 07:27, 5 April 2015. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
local getArgs = require('Module:Arguments').getArgs

local function ref( a )
	local refPattern = '<ref.+>'
	local p, _  = string.find( a or '', refPattern )
	local contentPart, refPart
	
	if p then
		contentPart = string.sub( a, 1, p -1 )
		refPart = string.sub( a, p )
	else
		contentPart = a or ''
		refPart = ''
	end
	
	return contentPart, refPart 
end

local p = {}

function p.main(frame)
	local args = getArgs(frame)
	return p._main(args)
end
 
function p._main(args)
	-- Main module code goes here.
	local ret

	local pt1, pt2 = ref( args[1] )

	ret = "<i>" .. pt1 .. "</i>" .. pt2

	return ret
end
	
return p