Module:Wd: Difference between revisions

Content deleted Content added
mNo edit summary
Fixed issue with -0 value; changed movable separator default under certain condition
Line 150:
end
 
-- used to merge output tablesarrays together;
-- note that it currently mutates the first input tablearray
function mergeTablesmergeArrays(t1a1, t2a2)
for i = 1, #t2a2 do
t1a1[#t1a1 + 1] = t2a2[i]
end
return t1a1
end
 
Line 231:
if i then
-- year
parts[index] = tonumber(mw.ustring.gsub(dateStr:sub(ptr, i-1), "^\+(.+)$", "%1"), 10) -- remove '+' sign (explicitly give base 10 to prevent error)
if parts[index] == -0 then
parts[index] = tonumber("0") -- for some reason, 'parts[index] = 0' may actually store '-0', so parse from string instead
parts[index] = 0
end
Line 526:
sorted = ranks[1]
sorted = mergeTablesmergeArrays(sorted, ranks[2])
sorted = mergeTablesmergeArrays(sorted, ranks[3])
return sorted
Line 817:
if numDigits < 0 or numDigits == -0 then
numDigits = tonumber("0") -- for some reason, 'numDigits = 0' may actually store '-0', so parse from string instead
numDigits = 0
end
Line 1,200:
for i, v in ipairs(formatTable) do
if v.param then
valuesArray = mergeTablesmergeArrays(valuesArray, result[v.str])
else
valuesArray[#valuesArray + 1] = {v.str}
Line 1,206:
if v.child then
valuesArray = mergeTablesmergeArrays(valuesArray, walk(v.child, result))
end
end
Line 1,230:
if #valuesArray > 0 then
valuesArray[#valuesArray + 1] = {sep}
out = mergeTablesmergeArrays(valuesArray, out)
end
end
Line 1,297:
end
out = mergeTablesmergeArrays(out, result[parameters.qualifier..i])
end
end
Line 1,628:
if args["format"] then
parsedFormat, formatParams = parseFormat(mw.text.trim(args["format"]))
elseif _.states.qualifiersCount > 0 then -- "qualifier(s)" command given
if _.states[parameters.property] then -- "propert(y|ies)" command given
parsedFormat, formatParams = parseFormat(formats.propertyWithQualifier)
else
parsedFormat, formatParams = parseFormat(formats.qualifier)
end
elseif _.states[parameters.property] then -- "propert(y|ies)" command given
parsedFormat, formatParams = parseFormat(formats.property)
else -- "reference(s)" command given
else
parsedFormat, formatParams = parseFormat(formats.reference)
end
-- if only "reference(s)" has been given, make the emtpy string the default separator (except when raw)
-- if a "qualifier(s)" command and no "propert(y|ies)" command has been given, make the movable separator a semicolon
if not _.states[parameters.reference].rawValue then
if _.states.qualifiersCount > 0 and not _.states[parameters.property] then
_.separators["sep"][1] = ""
_.separators["sep"..parameters.separator][1] = ";"
end
end
-- if only "reference(s)" has been given, make the emtpy string the default separator (except when raw)
if _.states[parameters.reference] and not _.states[parameters.property] and _.states.qualifiersCount == 0
if and not _.states[parameters.reference].rawValue then
_.separators["sep"][1] = ""
end