Changes
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()