Changes
Jump to navigation
Jump to search
step -- Get arguments without a number suffix, and check for bad input. for i,v in ipairs(prefixTable) do if type(v) ~= step 'table' or 20 type(v.prefix) ~= "string" or (v.depend and type(v.depend) ~= 'table') then error('Invalid input detected to preprocessArgs prefix table', 2) end preprocessSingleArg(v.prefix) -- If Only parse the step size depend parameter if the prefix parameter is present and not givenblank. if args[v.prefix] and v.depend then for j, the default is 20dependValue in ipairs(v.depend) do if type(dependValue) ~= 'string' then error('Invalid "depend" parameter value detected in preprocessArgs') end preprocessSingleArg(dependValue) end end end local temp-- Get arguments with number suffixes.
for j,v in ipairs(prefixTable) do
if not type(v) == "string" then
error("Non-string value detected in the prefix table in the touchParameters function.", 2)
end
temp = origArgs[v]
end
temp local prefixArgName = origArgs[v .prefix .. tostring(i)] if temp origArgs[prefixArgName] then moreArgumentsExist = true-- Do another loop if any arguments are found, even blank ones. preprocessSingleArg(prefixArgName) end -- Process the depend table if the prefix argument is present and not blank, or -- we are processing "prefix1" and "prefix" is present and not blank, and -- if the depend table is present. if v.depend and (args[prefixArgName] or (i == 1 and args[v.prefix])) then for j,dependValue in ipairs(v.depend) do local dependArgName = dependValue .. tostring(i) preprocessSingleArg(dependArgName) end
local origArgs
fix phantom reference bug
local HtmlBuilder = require('Module:HtmlBuilder')
local args= {}local origArgs
local root
end
local function touchParameterspreprocessSingleArg(prefixTable, origArgs, stepargName) -- Parse If the parameters with the given prefixesargument exists and isn't blank, in order, in batches -- of add it to the step size specifiedargument table. This is to prevent references etc. from -- appearing in Blank arguments are treated as nil to match the wrong orderbehaviour of ParserFunctions. if type(prefixTable) ~= 'table' or type(origArgs) [argName] and origArgs[argName] ~= 'table' then error("Invalid input to the touchParameters function detected. Both parameters must be tables.", 2)args[argName] = origArgs[argName]
end
end local function preprocessArgs(prefixTable, step) -- Assign the parameters with the given prefixes to the args table, in order, in batches -- of the step size specified. This is to prevent references etc. from appearing in the -- wrong order. The prefixTable should be an array containing tables, each of which has -- two possible fields, a "prefix" string and a "depend" table. The function always parses -- parameters containing the "prefix" string, but only parses parameters in the "depend" -- table if step the prefix parameter is present and non-blank. if type(prefixTable) ~= 'table' then error("Non-table value detected for the prefix table", 2) end if type(step) ~= 'number' then error("Non-numerical Invalid step value detected.", 2)
end
local a = 1 -- Counter variable.
local moreArgumentsExist = true
while moreArgumentsExist == true do
moreArgumentsExist = false
for i = a, a + step - 1 do
for j,v in ipairs(prefixTable) do
end
end
function p.infobox(frame)
-- If called via #invoke, use the args passed into the invoking template.
-- Otherwise, for testing purposes, assume args are being passed directly in.
-- Parse the data parameters in the same order that the old {{infobox}} did, so that
-- references etc. will display in the expected places.Parameters that depend on local temp-- another parameter are only processed if that parameter is present, to avoid temp = origArgs-- phantom references appearing in article reference lists. preprocessSingleArg('child') preprocessSingleArg('bodyclass') preprocessSingleArg('subbox') preprocessSingleArg('bodystyle') preprocessSingleArg('title') preprocessSingleArg('titleclass') temp = origArgs.preprocessSingleArg('titlestyle') preprocessSingleArg('above') preprocessSingleArg('aboveclass') preprocessSingleArg('abovestyle') touchParameterspreprocessArgs({ {prefix = 'subheader', depend = {'subheaderstyle', 'subheaderrowclass'}} }, origArgs, 510) preprocessSingleArg('subheaderstyle') preprocessSingleArg('subheaderclass') touchParameterspreprocessArgs({ {prefix = 'image', depend = {'caption', 'imagerowclass'}} }, origArgs, 510) preprocessSingleArg('captionstyle') preprocessSingleArg('imagestyle') preprocessSingleArg('imageclass') touchParameterspreprocessArgs({ {prefix = 'header'}, {prefix = 'data', depend = {'label', 'datarowclass'}}, origArgs, 20) temp {prefix = origArgs.below 'class'} -- ParserFunctions considers whitespace to be false}, so to preserve the previous 50) -- behavior of {{infobox}}, change any whitespace arguments to nil, so Lua will considerpreprocessSingleArg('headerstyle') -- them false too. preprocessSingleArg(Except the 'italic titlelabelstyle' param, which specifies different behavior) -- depending on whether itpreprocessSingleArg('datastyle's absent or empty) args = {}preprocessSingleArg('below') for k, v in pairspreprocessSingleArg(origArgs'belowclass') do if mw.ustring.match preprocessSingleArg(v, '%Sbelowstyle') or k == preprocessSingleArg('italic titlename' then) args[k'italic title'] = v endorigArgs['italic title'] -- different behaviour if blank or absent endpreprocessSingleArg('decat')
return _infobox()