Module:Convert: Difference between revisions

update from Module:Convert/sandbox: "warnings=1"
(an output combination unit can be user-defined, consisting of unit codes separated by "+" or " " (space))
(update from Module:Convert/sandbox: "warnings=1")
Line 217:
end
 
local function add_warning(parms, level, mcode, text)
-- If enabled, add a warning that will be displayed after the convert result.
-- To reduce output noise, only the first warning is displayed.
if boolean(config.warnings) then
if parmslevel <= (tonumber(config.warnings) ==or nil1) then
if parms.warnings == message({ mcode, textnil })then
parms.warnings = message({ mcode, text })
end
end
end
Line 243 ⟶ 245:
success, speller = pcall(get_speller, spell_module)
if not success or type(speller) ~= 'function' then
add_warning(parms, 1, 'cvt_no_spell')
return nil
end
Line 1,419 ⟶ 1,421:
-- as the latter is a deprecated alias for the former.
if kv_pairs.adj ~= kv_pairs.sing and kv_pairs.sing ~= '' then
add_warning(parms, 1, 'cvt_unknown_option', 'sing=' .. kv_pairs.sing)
end
kv_pairs.sing = nil
Line 1,429 ⟶ 1,431:
if en_name == 'sigfig' then
if loc_value == '' then
add_warning(parms, 2, 'cvt_empty_option', loc_name)
else
local number, is_integer = get_number(loc_value)
Line 1,435 ⟶ 1,437:
en_value = number
else
add_warning(parms, 1, 'cvt_bad_sigfig', loc_value)
end
end
Line 1,442 ⟶ 1,444:
if en_value == nil then
if loc_value == '' then
add_warning(parms, 2, 'cvt_empty_option', loc_name)
else
-- loc_value can no longer be nil here (at one time, that could occur
-- with aliases like |sing=off|adj=on), but am retaining safety check.
local text = loc_value and (loc_name .. '=' .. loc_value) or loc_name
add_warning(parms, 1, 'cvt_unknown_option', text)
end
elseif en_value == '' then
Line 1,460 ⟶ 1,462:
parms[en_name] = en_value
else
add_warning(parms, 1, 'cvt_unknown_option', loc_name .. '=' .. loc_value)
end
end
Line 1,678 ⟶ 1,680:
end
if is_bad_precision then
add_warning(parms, 1, 'cvt_bad_prec', precision)
else
parms.precision = precision
Anonymous user