Content deleted Content added
No edit summary
No edit summary
 
Line 119:
}
 
local hookNames = { -- {level_1, level_2}
[parameters.property] = {"getProperty"},
[parameters.reference] = {"getReferences", "getReference"},
Line 133:
["sep%q"] = {"; "},
["sep%q\\d"] = {", "},
["sep%r"] = nil, -- none
["punc"] = nil -- none
}
 
Line 366:
 
if dateStr == nil then
return parts[1], parts[2], parts[3] -- year, month, day
end
 
Line 403:
 
if i then
-- month
parts[index] = tonumber(dateStr:sub(ptr, i-1), 10)
 
if precision == "m" then
-- we're done
return parts[1], parts[2], parts[3]
end
Line 693 ⟶ 691:
 
for i = 1, #valuesArray do
-- check if this is a reference
if valuesArray[i].refHash then
j = i - 1
Line 1,062 ⟶ 1,059:
 
if qualifiers and qualifiers[1] then
return self:getValue(qualifiers[1], true) -- raw = true
else
return nil
Line 1,069 ⟶ 1,066:
 
function Config:snakEqualsValue(snak, value)
local snakValue = self:getValue(snak, true) -- raw = true
 
if snakValue and snak.snaktype == 'value' and snak.datavalue.type == 'wikibase-entityid' then value = value:upper() end
Line 1,192 ⟶ 1,189:
 
if self.periods[1] then
-- future
if startTimeY and datePrecedesDate(self.atDate[1], self.atDate[2], self.atDate[3], startTimeY, startTimeM, startTimeD) then
return true
Line 1,199 ⟶ 1,195:
 
if self.periods[2] then
-- current
if (startTimeY == nil or not datePrecedesDate(self.atDate[1], self.atDate[2], self.atDate[3], startTimeY, startTimeM, startTimeD)) and
(endTimeY == nil or datePrecedesDate(self.atDate[1], self.atDate[2], self.atDate[3], endTimeY, endTimeM, endTimeD)) then
Line 1,207 ⟶ 1,202:
 
if self.periods[3] then
-- former
if endTimeY and not datePrecedesDate(self.atDate[1], self.atDate[2], self.atDate[3], endTimeY, endTimeM, endTimeD) then
return true
Line 1,264 ⟶ 1,258:
return true
elseif flag == "" then
-- ignore empty flags and carry on
return true
else
Line 1,296 ⟶ 1,289:
self.states[param] = State:new(self, param)
 
self.states[param].parsedFormat = parseFormat(parameters.general) -- will be overwritten for param=="%p"
 
self.states[param].separator = self.separators["sep"..param] -- will be nil for param=="%p", which will be set separately
 
if flag == p.claimCommands.property or flag == p.claimCommands.qualifier or flag == p.claimCommands.reference then
Line 1,338 ⟶ 1,331:
 
function State:resetCaches()
-- any prefetched references of the previous claim must not be used
self.conf.prefetchedRefs = nil
end
Line 1,424 ⟶ 1,416:
end
 
-- level 1 hook
function State:getProperty(claim)
local value = {self:getValue(claim.mainsnak)}
Line 1,440 ⟶ 1,431:
if claim.qualifiers then qualifiers = claim.qualifiers[self.conf.qualifierIDs[param]] end
if qualifiers then
return self.conf.states[param]:iterate(qualifiers, {[parameters.general] = hookNames[parameters.qualifier.."\\d"][2], count = 1}) -- pass qualifier state with level 2 hook
else
return {}
Line 1,485 ⟶ 1,476:
 
if claim.references then
return self.conf.states[parameters.reference]:iterate(claim.references, {[parameters.general] = hookNames[parameters.reference][2], count = 1}) -- pass reference state with level 2 hook
else
return {}
Line 1,491 ⟶ 1,482:
end
 
-- level 2 hook
function State:getReference(statement)
local key, citeWeb, citeQ, label
Line 1,529 ⟶ 1,519:
 
if i == aliasesP.author then
params[i] = self:getReferenceDetails(statement.snaks, i, false, self.linked, true) -- link = true/false, anyLang = true
else
params[i] = {self:getReferenceDetail(statement.snaks, i, false, (self.linked or (i == aliasesP.statedIn)) and (statement.snaks[i][1].datatype ~= 'url'), true)} -- link = true/false, anyLang = true
end
 
Line 1,575 ⟶ 1,565:
 
elseif citeQ and not citeMismatch['q'] and citeParams['q'][i18n['cite']['q'][aliasesP.statedIn]] then
citeParams['q'][i18n['cite']['q'][aliasesP.statedIn]] = self:getReferenceDetail(statement.snaks, aliasesP.statedIn, true) -- raw = true
 
useCite = citeQ
Line 1,632 ⟶ 1,622:
 
if value ~= "" then
value = {value} -- create one value object
 
if not self.rawValue then
Line 1,680 ⟶ 1,670:
 
for _, v in ipairs(snaks[dType]) do
values[#values + 1] = self.conf:getValue(v, raw, link, false, anyLang, false, true) -- noSpecial = true
end
 
Line 1,929 ⟶ 1,919:
end
 
-- parse the desired format, or choose an appropriate format
if args["format"] then
parsedFormat, formatParams = parseFormat(args["format"])