Mô đun:Hiển thị Lập lịch theo tuần

Tài liệu mô đun[tạo]
local p = {};

p.init = function( frame )
	local pagename = mw.text.trim( frame.args[1] )

	local content = mw.text.trim( mw.title.new( pagename ):getContent() )
	local lines = mw.text.split( content, "\n" )
	
	local result = mw.html.create( "div" ):attr( "class", "register-list" )
	local list = mw.html.create( "ul" )

	-- get year
	local year = string.sub( pagename, -4 )
	
	-- generate list
	for _, line in pairs(lines) do
		if string.find( line, "@" ) then
			local item = mw.html.create( "li" ):wikitext( weeklabel( line ) .. " " .. line  )
			list:node( item )
		end
	end

	return tostring( result:node( list ) )
end

function weeklabel( line )
	local result
	local matcher = mw.ustring.match ( line, "@.*@" )
	result = mw.ustring.sub( matcher, 3, -3 )
	return result
end

return p