Content deleted Content added
update from sandbox per Template talk:Convert#Module version 17 |
update from sandbox per Template talk:Convert#Module version 25 |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 215:
-- very likely that any decision a module makes about how to handle data
-- will be wrong for some cases at some time. This meets current requirements.
-- For each qualifier (or if no
-- statements, use them and ignore any normal statements.
-- For each qualifier, for the preferred statements if any, or for
Line 277:
end
local function input_from_text(tdata, parms, text, insert2)
-- Given string should be of form "<value><space><unit>"
-- "<value1><space>ft<space><value2><space>in" for a special case (feet and inches).
-- Return
text = text:gsub(' ', ' '):gsub('
local pos = text:find(' ', 1, true)
if pos then
Line 286 ⟶ 287:
local value = text:sub(1, pos - 1)
local uid = text:sub(pos + 1)
if uid:sub(1, 3) == 'ft ' and uid:sub(-3) == ' in' then
local ucode = make_unit(tdata.wikidata_units, parms, uid)▼
-- Special case for enwiki to allow {{convert|input=5 ft 10+1/2 in}}
insert2(uid:sub(4, -4), 'in')
insert2(value, 'ft')
else
end
return true
end
end
Line 300 ⟶ 307:
local text = parms.input -- should be a trimmed, non-empty string
local pid = text:match('^P%d+$')
local sep = ','
local special = specials[parms[index]]
if special then
Line 310 ⟶ 317:
return false, pid and { 'cvt_no_output' } or { 'cvt_bad_input', text }
end
local function
table.insert(parms, index, second)
table.insert(parms, index, first)
Line 330 ⟶ 337:
end
local item = ucode
if item == parms[index] then
-- Remove specified output unit if it is the same as the Wikidata unit.
-- For example, {{convert|input=P2044|km}} with property "12 km".
table.remove(parms, index)
end
for i = result.n, 1, -1 do
item = sep
end
return true
else
return true
end
Line 473 ⟶ 483:
end
if k == 'label' then
local wdl = mw.wikibase.
if wdl ~= value then
note:add('label changed to ' .. tostring(wdl))
|