metanorma-standoc 3.5.20 → 3.5.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/metanorma/converter/macros_number.rb +20 -10
- data/lib/metanorma/standoc/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9e40f28438ac296b76abe4f4ac62bc284e2adc46be113c447c390a3c9a45f81d
|
|
4
|
+
data.tar.gz: 523dea5caaaf8c1e3cc3822264266ff0c4cd3d10709d907472e5988040fdefe1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e8c531af2c9b725f3ac254da417858189eef283aa9dc23b2a818f550f9ae02dd9b88b71c1bfd10bed2ba5bebe25f856d0c402fd87d8a9ee1ae60154fca323705
|
|
7
|
+
data.tar.gz: efb9d3d13459c7bf0facf770d0e6b568f11d32c26a7ea4cbf6c907e431cf462b23e82868eef40c32b9c9cbf4f2dfa0082443da17a487fbd5caf86a5de36c9525
|
|
@@ -43,16 +43,10 @@ module Metanorma
|
|
|
43
43
|
[integer_part, fractional_part]
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
-
#
|
|
46
|
+
# The value emitted into <mn> is canonical positional decimal:
|
|
47
|
+
# the exponent form is a rendering decision driven by the
|
|
48
|
+
# number-format attributes, not baked into the semantic content.
|
|
47
49
|
def number(text)
|
|
48
|
-
n = BigDecimal(number_base(text))
|
|
49
|
-
trailing_zeroes = 0
|
|
50
|
-
m = /\.[1-9]*(0+)/.match(text) and trailing_zeroes += m[1].size
|
|
51
|
-
n.to_s("E").sub("e", "0" * trailing_zeroes + "e") # rubocop:disable Style/StringConcatenation
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
# Detect prefix and convert to decimal
|
|
55
|
-
def number_base(text)
|
|
56
50
|
case text.strip
|
|
57
51
|
when /^0[xX]([0-9A-Fa-f.]+)$/
|
|
58
52
|
parse_number_with_base(Regexp.last_match(1), 16)
|
|
@@ -60,9 +54,25 @@ module Metanorma
|
|
|
60
54
|
parse_number_with_base(Regexp.last_match(1), 2)
|
|
61
55
|
when /^0[oO]([0-7.]+)$/
|
|
62
56
|
parse_number_with_base(Regexp.last_match(1), 8)
|
|
57
|
+
when /\A[0-9]+(\.[0-9]+)?[eE][+-]?[0-9]+\z/
|
|
58
|
+
BigDecimal(text.strip).to_s("F").sub(/\.0\z/, "")
|
|
59
|
+
when /\A[0-9]+(\.[0-9]+)?\z/
|
|
60
|
+
text.strip # Regular decimal - pass through
|
|
63
61
|
else
|
|
64
|
-
text
|
|
62
|
+
BigDecimal(text.strip).to_s("F").sub(/\.0\z/, "")
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Handle numbers with fractional parts in different bases
|
|
67
|
+
# Split on decimal point
|
|
68
|
+
def parse_number_with_base(num_str, base)
|
|
69
|
+
integer_part, fractional_part = split_number(num_str)
|
|
70
|
+
int_value = integer_part.to_i(base)
|
|
71
|
+
return int_value.to_s if fractional_part.empty?
|
|
72
|
+
frac_value = fractional_part.chars.each_with_index.sum do |digit, index|
|
|
73
|
+
BigDecimal(digit.to_i(base).to_s) / BigDecimal((base**(index + 1)).to_s)
|
|
65
74
|
end
|
|
75
|
+
(BigDecimal(int_value.to_s) + frac_value).to_s("F")
|
|
66
76
|
end
|
|
67
77
|
|
|
68
78
|
def process(parent, target, attrs)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: metanorma-standoc
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.5.
|
|
4
|
+
version: 3.5.21
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: addressable
|