Module:Val: Difference between revisions

Content deleted Content added
built-in units can be flagged as SI so they scale relative to each other; four-digit integers are not formatted with gaps to match template
a built-in unit can be an alias for a unit defined in convert
Line 106:
local text = definitions:sub(pos, endline - 1):gsub('%s%s+', '\t')
for item in (text .. '\t'):gmatch('(%S.-)\t') do
if item == 'NOSPACEALIAS' then
result.nospacealias = true
elseif item == 'ANGLE' then
result.isangle = true
result.nospace = true
elseif item == 'NOSPACE' then
result.nospace = true
elseif item == 'SI' then
Line 126 ⟶ 128:
end
end
if n >= 2 or (n >= 1 and result.alias) then
return result
end
Line 154 ⟶ 156:
get_builtin_unit(ucode, data.builtin_units_long_scale) or
get_builtin_unit(ucode, data.builtin_units)
local si, use_result
if result then
use_result = true
if result.alias then
ucode = result.symbol
use_result = false
end
if result.scale then
value = value * result.scale
Line 161 ⟶ 168:
if result.si then
si = { result.symbol, result.link }
use_result = false
end
end
local convert_unit = convert_lookup(ucode, value, scaled_top, want_link, si, options)
if result and not result.siuse_result then
if want_link then
result.text = '[[' .. result.link .. '|' .. result.symbol .. ']]'