Dokumentado Dokumentado


Ŝablona programado Diskutoj Lua Testoj Subpaĝoj
Modulo Esperanto English

Modulo: Dokumentado


Se vi havas demandon pri ĉi tiu Lua-modulo, tiam vi povas demandi en la diskutejo pri Lua-moduloj. La Intervikiaj ligiloj estu metataj al Vikidatumoj. (Vidu Helpopaĝon pri tio.)
-- Babel -- 20220530

function subtitle(text)
	-- This function builds subtitles in the box
				local sub_title = mw.html.create('table')
				  :css('text-align','center')
				  :css('width','100%')
				  :css('margin','0 auto')
				local row =  sub_title:tag('tr')
				local sub_title_cell =  row:tag('th')
				   :css('background-color','#EEFFCC')
				   :css('border','1px dotted #FFCC99')
				   :css('padding','0.3em')				   
				   :wikitext(text)
				   :done()
				return tostring(sub_title)
end	

function placeholder(text)
	-- This function builds placeholders in the box
				local height = "45px"	
				local t1 = tonumber(text)
				if t1 then
					height = t1 .. ".px"
				end
				local t = " "
				local place = mw.html.create('table')
				  :css('text-align','center')
				  :css('width','100%')
				  :css('margin','0 auto')
				local row =  place:tag('tr')
				local place_cell =  row:tag('th')
				   :css('height',height)	
				   :css('padding','0.3em')				   
				   :wikitext(t)
				   :done()
				return tostring(place)
end	

function line (text)
	-- This function builds lines in the box
				local line_div = mw.html.create('div')
				   :css('float','left')
				   :css('width','238px')
				   :css('height','1.5px')
				   :css('margin','1px')
				   :css('background-color','#EEEEEE')
				   :css('border','1px solid #EEEEEE')
				   :wikitext(text)
				   :done()
				return tostring(line_div)			
end	

function beginonly (text,s,c)
		-- changes html codes for the tabel's beginning into wiki codes
		-- removes the end of the table
		-- html	
		local b1 = '<table class="userboxes"'
		local b2 = '><tr><th colspan="' .. s .. '" style="background%-color:' .. c .. ';text%-align:center">'
		local b3 = "</th></tr><tr>"
		-- wiki code
		local b1w = '{|  class="userboxes"'
		local b2w = '\n|-\n! colspan="' .. s .. '" style="background-color:' .. c .. ';text-align:center" | '
		local b3w = "\n<tr>"
		
		local r = text
		
		r = mw.ustring.gsub(r,b1,b1w,1) -- <table ... -> {| ...
		r = mw.ustring.gsub(r,b2,b2w,1) -- <tr><th> ... -> |- !
		r = mw.ustring.gsub(r,b3,b3w,1) -- </tr><tr> -> <tr>
		r = mw.ustring.sub(r,1,-9)      -- </table> -> nothing
		
		return r
end	

local p = {}

function p._babel_x(babels,args)
	-- this function builds the box used by the {{Babel-x}} template
	args.header = args.header or args.kaplinio or "[[Vikipedio:Babel]]" 
	args.footer = args.footer or args.piedlinio or "'''[[:Kategorio:Vikipediistoj laŭ lingvo]]'''" 
	args['extra-css'] = 'background-color:#FFFFFF;'
	return p._babel(babels,args)
end

function p._babel_l(b,args)
	-- this function builds the box used by the {{BabelLandoj}} and {{BabelDevenLoĝLoko}} templates
	local babels = {}
	-- copies some named parameters from {{BabelLandoj}} into unnamed for the modul
	local i = 1
	for k, v in pairs(args) do
		local x = args['l' .. i]
		if type(x) == "string" then
			x = mw.text.trim(x)
		end	
		if x ~= "" then
			babels[i] = x
			i = i + 1
		end
	end
	if args['common box'] == "yes" or args['komuna kesto'] =="jes" then
		args.header = args.header or args.kaplinio or "[[Vikipedio:Babel]]" 
		args.footer = args.footer or args.piedlinio or "'''[[:Kategorio:Vikipediistoj laŭ lingvo]]'''" 		
		args['extra-css'] = 'background-color:#FFFFFF;'
		--shows it like the {{Babel}} template
		return p._babel(babels,args)
	else	
		-- shows it like the old {{BabelLandoj}} and {{BabelDevenLoĝLoko}}
		local empty = {}
		empty.header = args.header or args.kaplinio or "[[Vikipedio:Babel]]" 
		empty.footer = args.footer or args.piedlinio or "'''[[:Kategorio:Vikipediistoj laŭ lingvo]]'''" 
		empty['extra-css'] = 'background-color:#FFFFFF;'
		empty.align = args.align or args.floso
		local align = "float-right" -- for the complete box
		local align2 = "right"      -- for the internal box 
		if empty.align == "left" then
			align = "float-left"
			align2 = "left"
		end		
		-- creates the external table
		local ret = mw.html.create('table')
				:css('border','none')
				:css('width','100px')
				:addClass(align)
		local row1 = ret:tag('tr')
		local bab = row1:tag('td')
		-- puts the babel information into the first table cell
		local bab_cell = p._babel(babels, empty)
		
		bab:wikitext(bab_cell)
			:done()
		
		local k = args.kat or 'jes'
		local frame = mw.getCurrentFrame()	
			-- code for the template {{DevenLoĝLoko}}
	if args.devenlando ~= nil and args.devenlando ~= "" then
			-- creates the second table cell		
		    local row2 = ret:tag('tr')
		    local der = row2:tag('td')
			local dl1 = args.devenlando
			local dl2 = args.devenloko or ""
			local dl3 = args.devenlokspeco or ""
			local ll1 = args['loĝlando'] or ""
			local ll2 = args['loĝloko'] or ""
			local ll3 = args['loĝlokspeco'] or ""
			local n = args.nomo or ""
			der:wikitext( frame:preprocess('{{DevenLoĝLoko|devenlando=' 
				.. dl1 .. '|devenloko=' .. dl2 .. '|devenlokspeco=' .. dl3 .. '|loĝlando='
				.. ll1 .. '|loĝloko=' .. ll2 .. '|loĝlokspeco=' .. ll3 				
				.. '|nomo=' .. n .. '|kat=' .. k .. '|babel-larĝo=jes|floso=' .. align2 .. '}}') )
				:done()
	end	
		
		return tostring(ret)
	end

end -- babel_l

function p._babel_l2(b,args)
	-- this function builds the box used by the {{BabelLoko}} template
	local babels = {}
	-- copies some named parameters from {{BabelLoko}} into unnamed for the modul
	local i = 1
	for k, v in pairs(args) do
		local x = args['l' .. i]
		if type(x) == "string" then
			x = mw.text.trim(x)
		end	
		if x ~= "" then
			babels[i] = x
			i = i + 1
		end
	end
	if args['common box'] == "yes" or args['komuna kesto'] =="jes" then
		args.header = args.header or args.kaplinio or "[[Vikipedio:Babel]]" 
		args.footer = args.footer or args.piedlinio or "'''[[:Kategorio:Vikipediistoj laŭ lingvo]]'''" 
		args['extra-css'] = 'background-color:#FFFFFF;'
		args['flag'] = 'no'
		--shows it like the {{Babel}} template
		return p._babel(babels,args)
	else	
		-- shows it like the old {{BabelLoko}}
		local empty = {}
		empty.header = args.header or args.kaplinio or "[[Vikipedio:Babel]]" 
		empty.footer = args.footer or args.piedlinio or "'''[[:Kategorio:Vikipediistoj laŭ lingvo]]'''" 
		empty['extra-css'] = 'background-color:#FFFFFF;'
		empty.align = args.align or args.floso
		local align = "float-right"
		if empty.align == "left" then
			align = "float-left"
		end			
		-- creates the external table
		local ret = mw.html.create('table')
				:css('border','none')
				:css('width','100px')
				:addClass(align)
		local row1 = ret:tag('tr')
		local bab = row1:tag('td')
		-- puts the babel information into the first table cell
		local bab_cell = p._babel(babels, empty)
		
		bab:wikitext(bab_cell)
			:done()
		
		local k = args.kat or 'jes'
		local frame = mw.getCurrentFrame()	
			-- code for the template {{Loko}}
	if args.lando ~= nil and args.lando ~= "" then
			-- creates the second table cell		
		    local row2 = ret:tag('tr')
		    local der = row2:tag('td')
			local l1 = args.lando
			local l2 = args.loko or ""
			local n = args.Nomo or ""
			der:wikitext(frame:preprocess('{{Loko|1=' 
				.. l1 .. '|2=' .. l2 .. '|3=' .. n .. '|kat=' .. k .. '|babel-larĝo=jes}}') )
				:done()
	end	
		
		return tostring(ret)
	end

end -- babel_l2

function p._babel_l3(b,args)
	-- this function builds the box used by the {{BabelLando}} template
	local babels = {}
	-- copies some named parameters from {{BabelLando}} into unnamed for the modul
	local i = 1
	for k, v in pairs(args) do
		local x = args['l' .. i]
		if type(x) == "string" then
			x = mw.text.trim(x)
		end	
		if x ~= "" then
			babels[i] = x
			i = i + 1
		end
	end
	if args['common box'] == "yes" or args['komuna kesto'] =="jes" then
		args.header = args.header or args.kaplinio or "[[Vikipedio:Babel]]" 
		args.footer = args.footer or args.piedlinio or "'''[[:Kategorio:Vikipediistoj laŭ lingvo]]'''" 		
		args['extra-css'] = 'background-color:#FFFFFF;'
		--shows it like the {{Babel}} template
		return p._babel(babels,args)
	else	
		-- shows it like the old {{BabelLando}}
		local empty = {}
		empty.header = args.header or args.kaplinio or "[[Vikipedio:Babel]]" 
		empty.footer = args.footer or args.piedlinio or "'''[[:Kategorio:Vikipediistoj laŭ lingvo]]'''" 
		empty['extra-css'] = 'background-color:#FFFFFF;'
		empty.align = args.align or args.floso
		local align = "float-right" -- for the complete box
		local align2 = "right"      -- for the internal box 
		if empty.align == "left" then
			align = "float-left"
			align2 = "left"
		end		
		-- creates the external table
		local ret = mw.html.create('table')
				:css('border','none')
				:css('width','100px')
				:addClass(align)
		local row1 = ret:tag('tr')
		local bab = row1:tag('td')
		-- puts the babel information into the first table cell
		local bab_cell = p._babel(babels, empty)
		
		bab:wikitext(bab_cell)
			:done()
		
		local k = args.kat or 'jes'
		local frame = mw.getCurrentFrame()	
			-- code for the template {{UzantoLando}}
	if args.lando ~= nil and args.lando ~= "" then
			-- creates the second table cell		
		    local row2 = ret:tag('tr')
		    local der = row2:tag('td')
			local l1 = args.lando
			local l2 = args.loko or ""
			local l3 = args.lokospeco or ""
			local n = args.nomo or "{{PAGENAME}}"
			der:wikitext( frame:preprocess('{{UzantoLando|lando=' 
				.. l1 .. '|loko=' .. l2 .. '|lokospeco=' .. l3 .. 	 '|nomo=' 
				.. n .. '|kat=' .. k .. '|babel-larĝo=jes|floso=' .. align2 .. '}}') )
				:done()
	end	
		
		return tostring(ret)
	end

end -- babel_l3

function p._babel(babels, args)  
	-- This function builds the babel box used by the {{babel}} template.
	local fl = args.align or args.floso
	-- variables for the margins
	local l = "1"
	local r = "0"
	if fl == "left" then
		l = "0"
		r = "1"
	end		
	local ret = mw.html.create('table')
				:addClass('userboxes')
				:css( {
						float = args.align or args.floso or 'right',
						['margin-left'] = l .. 'em',
						['margin-right'] = r .. 'em',
						['margin-bottom'] = (args.bottom or args['malsupra marĝeno'] or '0') .. 'em',
						width = (args.width or args['larĝo'] or '248') .. 'px',
						clear = args.align or args.floso or 'right',
						color = args.textcolor or args['teksta koloro'] or '#000000',
						border = (args.bordercolor or args['randkoloro'] or '#99B3FF') .. ' solid ' .. (args.solid or args['linilarĝo'] or 1) ..'px'
					} )
				
 	if (args.shadow and string.lower(args.shadow) == 'yes') or (args.ombro and string.lower(args.ombro) == 'jes')  then
		ret:css({ ['-webkit-box-shadow'] = '0 2px 4px rgb(0,0,0,0.2)',
				  ['-moz-box-shadow'] = '0 2px 4px rgb(0,0,0,0.2)',
				  ['box-shadow'] = '0 2px 4px rgb(0,0,0,0.2)' })
	end
	
	-- formats from {{Bordera radiuso}}  and the old {{Babel}}
	ret:css({ ['-webkit-border-radius'] = '0.6em',
			  ['-moz-border-radius'] = '0.6em',
			  ['border-radius'] = '0.6em' })
	
	ret:cssText( args['extra-css'] or '' )
 
	local color = args.color or args.fonkoloro or 'inherit'
	local row1 = ret:tag('tr')
	local row2 = ret:tag('tr')
	local row3 = ret:tag('tr')
 
	local body_cells = row2:tag('td')
				:css('vertical-align', 'top !important')	
				
	local userboxes
	local k = args.kat or 'jes'
	local frame = mw.getCurrentFrame()	
	-- Special message for when first argument is blank; otherwise treat it as normal
	if babels[1] and babels[1]:find('%S') then
		if mw.ustring.sub(babels[1],1,2) == "[[" then
			body_cells:wikitext(babels[1])
		elseif mw.ustring.sub(babels[1],1,2) == "{{" and mw.ustring.sub(babels[1],1,3) ~= "{{{" then		
			body_cells:wikitext(babels[1])
		elseif mw.ustring.sub(babels[1],1,1) == "<" then		
			body_cells:wikitext(babels[1])
		elseif mw.ustring.sub(babels[1],1,2) == "##" then
				local v = mw.ustring.sub(babels[1],3)
				body_cells:wikitext(subtitle(v))	
		elseif mw.ustring.sub(babels[1],1,2) == "--" then
				local v = mw.ustring.sub(babels[1],3)
				body_cells:wikitext(placeholder(v))	
		-- code for {{#Babel, because the parser analyzed this before Lua can work			
		elseif mw.ustring.sub(babels[1],1,3) == "#b#" or mw.ustring.sub(babels[1],1,3) == "#B#"	then
				local v = mw.ustring.sub(babels[1],4) 
				-- removes the internal links 
				v = mw.ustring.gsub(v,"%[%[Project:Babel%|Babela informo pri uzanto%]%]","",1)
				v = mw.ustring.gsub(v,"%[%[:Kategorio:Vikipediistoj laŭ_lingvo%|Serĉu uzulajn lingvojn%]%]","",1)				
				v = '<div style="width:246px; float:left;">' .. v .. "</div>"
				body_cells:wikitext(v)
		elseif mw.ustring.sub(babels[1],1,1) == "~" then		
				body_cells:wikitext(line())					
		else	
			userboxes = frame:preprocess('{{Uzulo|'..babels[1]..'|kat=' .. k .. '|babel-larĝo=jes|floso=left}}')
		end
	else
		userboxes = args.noboxestext or "''Ĉi tiu uzanto scipovas nek legi nek skribi iun ajn lingvon. [[Ŝablono:Babelejo/dokumentado|Helpo]] necesas.''"
	end
 
	body_cells:wikitext(userboxes)				

	-- "remove" args[1] so it isn't looked at in the loop
	-- table.remove(args,1) doesn't produce desired result
	babels[1] = ''
 
	-- Keep track of how many columns are in this table
	local col_span = 1
	for _, v in ipairs( babels ) do
		-- ! indicates a new cell should be created
		if v:find('%S') and v ~= '!' then
			if mw.ustring.sub(v,1,2) == "[[" then
				body_cells:wikitext(v)
			elseif mw.ustring.sub(v,1,2) == "{{" and mw.ustring.sub(v,1,3) ~= "{{{" then	
				body_cells:wikitext(v)
			elseif mw.ustring.sub(v,1,1) == "<" then
				body_cells:wikitext(v)	
			-- converts the text with ## at the begining into subtitle	
			elseif mw.ustring.sub(v,1,2) == "##" then
				v = mw.ustring.sub(v,3)
				body_cells:wikitext(subtitle(v))
			elseif mw.ustring.sub(v,1,2) == "--" then
				v = mw.ustring.sub(v,3)
				body_cells:wikitext(placeholder(v))	
			elseif mw.ustring.sub(v,1,1) == "~" then
				body_cells:wikitext(line())	
			-- code for {{#Babel, because the parser analyzed this before Lua can work						
			elseif mw.ustring.sub(v,1,3) == "#b#" or mw.ustring.sub(v,1,3) == "#B#"	then
				v = mw.ustring.sub(v,4) 
				-- removes the internal links 
				v = mw.ustring.gsub(v,"%[%[Project:Babel%|Babela informo pri uzanto%]%]","",1)
				v = mw.ustring.gsub(v,"%[%[:Kategorio:Vikipediistoj laŭ_lingvo%|Serĉu uzulajn lingvojn%]%]","",1)
				v = '<div style="width:246px; float:left;">' .. v .. "</div>"
				body_cells:wikitext(v)					
			else	
				body_cells:wikitext( frame:preprocess('{{Uzulo|'..v..'|kat=' .. k .. '|babel-larĝo=jes|floso=left}}') )
			end
		-- Recycling body_cells for <td>
		elseif v and v == '!' then
			col_span = col_span + 1
			body_cells:done()
			body_cells = row2:tag('td')
		end
	end
 
	if (args.header ~= "whitout") and (args.header ~= "sen") and (args.kaplinio ~= "sen") then
	local header = args.header or args.kaplinio
	row1:tag('th')
			:css({ ['background-color'] = color,
					['text-align'] = 'center' })
			:attr('colspan',col_span)
			:wikitext( header or '[[Vikipedio:Babelejo]]' )
			:done()
	end

 	if (args.footer ~= "whitout") and (args.footer ~= "sen") and (args.piedlinio ~="sen") and args['begin only'] ~="yes" and args['nur komenco'] ~="jes" then
 	local footer = args.footer or args.piedlinio
	row3:tag('td')
			:css({ ['background-color'] = color,
					['text-align'] = 'center' })
			:attr('colspan',col_span)
			:wikitext( footer or '[[:Kategorio:Vikipediistoj laŭ lingvo|Uzantoj laŭ lingvo]]' )
			:done()
	end	
	

			-- code for the templates {{UzantoLando}}, {{UzantoLandoFlago}} and {{Lando}}
			if args.lando ~= nil and args.lando ~= "" then
			local l1 = args.lando
			local l2 = args.loko or ""
			local l3 = args.lokospeco or ""
			local n = args.nomo or args.Nomo or ""
			local flag = args.flag or args.flago			
			-- for title before the information about the user's country
			local title = args['lando-titolo'] or ""
				if title ~= "" then
					body_cells:wikitext(subtitle(title))
				end

				if flag == "yes" or flag == "jes" or flag == nil or flag == "" then
				-- little box with flag				
					body_cells:wikitext( frame:preprocess('{{UzantoLando|lando=' .. l1 .. '|loko=' .. l2 
					.. '|lokospeco=' .. l3 .. '|nomo=' .. n .. '|kat=' .. k .. '|babel-larĝo=jes|floso=left}}') )
				elseif flag == "no" or flago == "ne" then		
				-- little box without flag			
					body_cells:wikitext( frame:preprocess('{{Loko|1=' 
					.. l1 .. '|2=' .. l2 .. '|3=' .. n .. '|kat=' .. k .. '|babel-larĝo=jes}}') )	
				elseif mw.ustring.sub(flag,-4,-1) == ".jpg" or mw.ustring.sub(flag,-4,-1) == ".png"
				or mw.ustring.sub(flag,-4,-1) == ".svg" or mw.ustring.sub(flag,-5,-1) == ".jpeg" then
					local f = flag 
					body_cells:wikitext( frame:preprocess('{{UzantoLandoFlago|lando=' .. l1 .. '|loko=' .. l2 
					.. '|lokospeco=' .. l3 .. '|nomo=' .. n .. '|flagloko=' .. f .. '}}') )
				else
					body_cells:wikitext( frame:preprocess('{{UzantoLando|lando=' .. l1 .. '|loko=' .. l2 
					.. '|lokospeco=' .. l3 .. '|nomo=' .. n .. '|kat=' .. k .. '|babel-larĝo=jes|floso=left}}') )			
				end

			end
	
	-- code for the template {{DevenLoĝLoko}}
	if args.devenlando ~= nil and args.devenlando ~= "" then
			local dl1 = args.devenlando
			local dl2 = args.devenloko or ""
			local dl3 = args.devenlokspeco or ""
			local ll1 = args['loĝlando'] or ""
			local ll2 = args['loĝloko'] or ""
			local ll3 = args['loĝlokspeco'] or ""
			local n = args.nomo or ""
			-- for title before the information about the user's countries
			local title = args['devenlando-titolo'] or ""				
			if title ~= "" then
				body_cells:wikitext(subtitle(title))
			end				
			body_cells:wikitext( frame:preprocess('{{DevenLoĝLoko|devenlando=' 
				.. dl1 .. '|devenloko=' .. dl2 .. '|devenlokspeco=' .. dl3 .. '|loĝlando='
				.. ll1 .. '|loĝloko=' .. ll2 .. '|loĝlokspeco=' .. ll3 				
				.. '|nomo=' .. n .. '|kat=' .. k .. '|babel-larĝo=jes|floso=left|marĝeno=0}}') )
	end	
	
	-- code for the template {{UTC}}
	if args.UTC ~= nil and args.UTC ~= "" then
			local u = args.UTC
			-- for title before the information about the user's UTC
			local title = args['UTC-titolo'] or ""
			if title ~= "" then
				body_cells:wikitext(subtitle(title))				
			end
			body_cells:wikitext( frame:preprocess('{{UTC|' ..u .. '|kat=' .. k .. '|babel-larĝo=jes|floso=left}}') )
	end	
	
	-- code for the template {{Uzanto SUL}}
	if args['sul-projekto'] ~= nil and args['sul-projekto'] ~= "" then
			local p = args['sul-projekto']
			local l = args['sul-lingvo'] or ""
			-- for title before the information about the user's SUL
			local title = args['sul-titolo'] or ""
			if title ~= "" then
				body_cells:wikitext(subtitle(title))				
			end			
			body_cells:wikitext( frame:preprocess('{{Uzanto SUL|1=' .. l .. '|2=' .. p 
				.. '|nocat=' .. k .. '|babel-larĝo=jes|floso=left}}') )
	end		
	
	-- for special boxes
	local maxspec = 15
	if args['speciala kesto'] then
			-- for a title before the special box
			local title = args['specialkesta titolo'] or ""
			if title ~= "" then
				body_cells:wikitext(subtitle(title))
			end		
		local s = args['speciala kesto']		
		body_cells:wikitext(s)
	end
	for i = 2, maxspec do
		local s = args['speciala kesto' .. i] or ""
		if s ~="" then
			-- for a title before the special box
			local title = args['specialkesta' .. i .. " titolo"] or ""
			if title ~= "" then
				body_cells:wikitext(subtitle(title))
			end				
			body_cells:wikitext(s)
		end
	end	

 
	if args['special-boxes'] or args['specialaj kestoj'] then
		local sp = args['special-boxes'] or args['specialaj kestoj']
		body_cells:wikitext(sp)
	end
 
	body_cells:done()
	
	local result = tostring(ret)
	
	-- change the html coding of the tabel's beginning into wiki code
	-- remove the end of the html coding of the table
	if args['begin only'] =="yes" or args['nur komenco'] =="jes" then
		local s = col_span
		result = beginonly (result,s,color)
 	end
 
	return result
	
end


local function processBabelArgs(args)
	-- This function processes a table of arguments and returns two tables: an array of portal names for processing by ipairs, and a table of
	-- the named arguments that specify style options, etc. We need to use ipairs because we want to list all the portals in the order
	-- they were passed to the template, but we also want to be able to deal with positional arguments passed explicitly, for example
	-- {{portal|2=Politics}}. The behaviour of ipairs is undefined if nil values are present, so we need to make sure they are all removed.
	args = type(args) == 'table' and args or {}
	local babels = {}
	local namedArgs = {}
	for k, v in pairs(args) do
		if type(k) == 'number' and type(v) == 'string' then -- Make sure we have no non-string babel names.
			table.insert(babels, k)
		elseif type(k) ~= 'number' then
			namedArgs[k] = v
		end
	end
	table.sort(babels)
	for i, v in ipairs(babels) do
		babels[i] = args[v]
	end
	return babels, namedArgs
end
 
local function makeWrapper(funcName)
	-- Processes external arguments and sends them to the alia functions.
	return function (frame)
		-- If called via #invoke, use the args passed into the invoking
		-- template, or the args passed to #invoke if any exist. Otherwise
		-- assume args are being passed directly in from the debug console
		-- or from another Lua modulo.
		local origArgs
		if frame == mw.getCurrentFrame() then
			origArgs = frame:getParent().args
			for k, v in pairs(frame.args) do
				origArgs = frame.args
				break
			end
		else
			origArgs = frame
		end
		-- Trim whitespace and remove blank arguments.
		local args = {}
		for k, v in pairs(origArgs) do
			if type(v) == 'string' then
				v = mw.text.trim(v)
			end
			if v ~= '' then
				args[k] = v
			end
		end
		return p[funcName](processBabelArgs(args)) -- passes two tables to func: an array of portal names, and a table of named arguments.
	end
end
 
local funcNames = {'babel', 'babel_x', 'babel_l', 'babel_l2', 'babel_l3'}
 
for _, funcName in ipairs(funcNames) do
	p[funcName] = makeWrapper('_' .. funcName)
end


return p