Module:Val:修订间差异
删除的内容 添加的内容
enwiki>Johnuniq change 0.3em spacing to 0.225em (same total space as old code) per Template talk:Val#Proposal to reduce spacing around ± 标签:已被回退 |
CaelLab-import(留言 | 贡献) huifu bei enwiki daoru dingti de banben (shangyiban zhwiki>阿南之人) 标签:手工回退 |
||
第1行:
-- For Template:Val, output a number and optional unit.
-- Format options include scientific and uncertainty notations.
local data_module = 'Module:Val/units'
第36行 ⟶ 第14行:
category = ''
else
category = '[[Category:
end
iswarning = false -- problems are infrequent so try showing large error so editor will notice
第46行 ⟶ 第24行:
else
body = '<strong class="error">' ..
'
msg ..
'</strong>'
第65行 ⟶ 第43行:
["×"] = " × ",
["/"] = "/",
["至"] = "至",
["到"] = "到",
}
local range_repeat_unit = {
第81行 ⟶ 第61行:
-- Input like 1e3 is regarded as invalid for all except argument 1
-- which accepts e notation as an alternative to the 'e' argument.
-- Input
local which = index
local function fail(msg)
local description
if which == 'e' then
description =
else
description =
end
return description
end
local result = {}
第98行 ⟶ 第78行:
if index == 2 then
if numbers[1] and numbers[1].exp then
return fail(
end
numbers.has_ranges = true
else
if not numbers.has_ranges then
return fail(
end
end
第113行 ⟶ 第93行:
return nil
end
return fail(
end
if numbers.has_ranges and type(index) == 'number' and (index % 2 == 0) then
return fail(
end
if index == 'e' then
第122行 ⟶ 第102行:
if e then
if arg then
return fail(
end
arg = e
第129行 ⟶ 第109行:
end
if arg and arg ~= '' then
arg = arg:gsub(
if arg:sub(1, 1) == '(' and arg:sub(-1) == ')' then
result.parens = true
第143行 ⟶ 第120行:
result.exp = b
else
return fail(
end
end
第197行 ⟶ 第174行:
end
if index > 19 then
return
end
end
if numbers.has_ranges and (#numbers % 2 == 0) then
return '在最后一个参数后需要一个数字,因为它是一个范围。'
end
end
第231行 ⟶ 第208行:
end
end
error(
end
第528行 ⟶ 第505行:
add(ucode .. ' = ' .. text .. '<br />')
else
add(line .. ' ◆ <b>
end
else
第539行 ⟶ 第516行:
local delimit_groups = require('Module:Gapnum').groups
local function delimit(sign, numstr, fmt)
-- Return sign and numstr (unsigned digits or
-- Four-digit integers are not formatted with gaps.
fmt = (fmt or ''):lower()
第550行 ⟶ 第527行:
local result
if fmt == 'commas' then
result = sign .. table.concat(ipart,
if dpart then
result = result ..
end
else
第562行 ⟶ 第539行:
end
if dpart then
table.insert(groups,
for _, v in ipairs(dpart) do
table.insert(groups, '<span style="margin-left:.25em;">' .. v .. '</span>')
第629行 ⟶ 第606行:
else
text = (angle or '') ..
'<span style="margin-left:0.
delimit('', uncU, fmt)
need_parens = true
第659行 ⟶ 第636行:
return list_units(options.align)
end
return valerror('
end
local number = values.number or (values.numbers and values.numbers[1]) or {}
第773行 ⟶ 第750行:
for k, v in pairs(args) do
if type(k) == 'string' and not whitelist[k] then
local warning =
return valerror(warning, nocat, true)
end
end
if not has_ranges and args[4] then
return valerror(
end
end
第792行 ⟶ 第769行:
end
if args.u and args.ul then
return valerror(
end
if args.up and args.upl then
return valerror(
end
local values
| |||