Module:Convert: Difference between revisions

(update from sandbox per Template talk:Convert#Module version 12)
(update from sandbox per Template talk:Convert#Module version 13)
Line 911:
end
return sep .. id .. mid
end
 
local function change_sign(text)
-- Change sign of text for correct appearance because it is negated.
if text:sub(1, 1) == '-' then
return text:sub(2)
end
return '-' .. text
end
 
Line 1,279 ⟶ 1,271:
-- with the hands unit (not worth adding code to enforce that).
------------------------------------------------------------------------
local numstr, whole
local leading_plus, prefix, numstr, slashes, denstr =
text:match('^%s*(%+?)%s*(.-)%s*(%d+)%s*(/+)%s*(%d+)%s*$')
Line 1,293 ⟶ 1,284:
return nil
end
local whole, wholestr
if prefix == '' then
wholestr = ''
Line 1,359 ⟶ 1,350:
while #remainder > 0 do
local ref, spaces
ref, spaces, remainder = remainder:match('^(\127UNIQ127[^\127]*UNIQ[^\127]*%-ref%-%x+%-QINU[^\127]*\127)(%s*)(.*)')
if ref then
table.insert(refs, ref)
Line 1,460 ⟶ 1,451:
end
end
local altvalue = altvalue or value
if isnegative and (value ~= 0) then
value = -value
altvalue = -(altvalue or value)
end
return true, {
value = value,
altvalue = altvalue or value,
singular = singular,
clean = clean,
Line 1,486 ⟶ 1,476:
local number = tonumber(to_en(text))
if number then
local integer_, fracpart = math.modf(number)
return number, (fracpart == 0)
end
Line 2,168 ⟶ 2,158:
local fudge = 1e-14 -- {{Order of magnitude}} adds this, so we do too
local prec, minprec, adjust
local utype = out_current.utype
local subunit_ignore_trailing_zero
local subunit_more_precision -- kludge for "in" used in input like "|2|ft|6|in"
Line 2,468 ⟶ 2,457:
outvalue = -outvalue
end
local numerator, precision, success, show, exponent
local denominator = out_current.frac
if denominator then
Line 2,936 ⟶ 2,925:
local abbr_org = parms.abbr_org
local adjectival = parms.opt_adjectival
local disp = parms.disp
local lk = parms.lk
local want_link = (lk == 'on' or lk == inout)
Line 3,514 ⟶ 3,502:
local success, parms, in_unit_table = get_parms(frame:getParent().args)
if success then
for i_ = 1, 2 do -- use counter so cannot get stuck repeating convert
success, result, out_unit_table = process(parms, in_unit_table, out_unit_table)
if success and parms.do_convert_again then
Anonymous user