Module:Convert: Difference between revisions

Jump to navigation Jump to search
large refactor of messages; show input when only output is invalid (and when reasonably easy to do so)
(fix valid_number check to account for Scribunto using 'nan' or 'inf' for problem numbers)
(large refactor of messages; show input when only output is invalid (and when reasonably easy to do so))
Line 199:
local msg = all_messages[mcode[1]]
if msg then
local texttitle = format(msg[1] or 'Missing message',
mcode[2] or '?',
mcode[3] or '?',
mcode[4] or '?')
local cattext = wanted_category(all_categories[msg[2]]) or 'Missing message'
local prefixcat = all_messageswanted_category(all_categories[msg.warning and 'cvt_prefix_warning' or 'cvt_prefix_error'[3]]) or ''
local suffixanchor = (prefix == '') and ''msg[4] or '</span>'
local fmt = all_messages['cvt_format'] or 'convert: bug'
local regex, replace = msg.regex, msg.replace
if regex and replace then
texttitle = texttitle:gsub(regex, replace)
end
title = title:gsub('"', '&quot;')
return prefixformat(fmt, ..anchor, ' ' ..title, text .., cat .. suffix)
end
return 'Convert internal error: unknown message'
Line 241 ⟶ 243:
success, speller = pcall(get_speller, spell_module)
if not success or type(speller) ~= 'function' then
add_warning(parms, 'cvt_spell_unavailablecvt_no_spell')
return nil
end
Line 1,640 ⟶ 1,642:
end
if is_bad_precision then
return falseadd_warning(parms, { 'cvt_bad_prec', precision })
else
parms.precision = precision
end
parms.precision = precision
return true, parms, in_unit_table
end
Line 2,635 ⟶ 2,638:
-- or return false, t where t is an error message table.
linked_pages = {}
local success, bad_output, out_unit_table
local invalue1 = in_unit_table.valinfo[1].value
local out_unit = parms.out_unit
if out_unit == nil or out_unit == '' then
success, out_unit = get_default(invalue1, in_unit_table)
if not success then return false, out_unit end
bad_output = out_unit
end
end
if mismatchnot bad_output then
success, out_unit_table = lookup(out_unit, parms.opt_sp_us, 'any_combination')
if not success, thenout_unit_table return= falselookup(out_unit, out_unit_tableparms.opt_sp_us, end'any_combination')
if success then
local mismatch = check_mismatch(in_unit_table, out_unit_table)
if mismatch then
return false, if mismatch then
bad_output = mismatch
end
else
bad_output = out_unit_table
end
end
local flipped = parms.opt_flip
Line 2,656 ⟶ 2,666:
if (part == 1 and not flipped) or (part == 2 and flipped) then
parts[part] = process_input(parms, in_unit_table)
elseif bad_output then
parts[part] = message(bad_output)
else
local outputs = {}
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu