isodoc 2.10.3 → 2.10.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/isodoc.gemspec +3 -1
- data/lib/isodoc/base_style/scripts.html +2 -2
- data/lib/isodoc/class_utils.rb +1 -1
- data/lib/isodoc/presentation_function/math.rb +66 -50
- data/lib/isodoc/presentation_xml_convert.rb +1 -1
- data/lib/isodoc/version.rb +1 -1
- metadata +31 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82d1c3ed71a05f100f76c7e3ff42ec7fd4fe27c2a018bb312a2639f27d69e8b1
|
4
|
+
data.tar.gz: b170bf5e893fb25d9506d34b7ee725c19cf7778270b724f3697a7ac56a487a98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca60c3933004e3b6b5ebcf1864baf52ebe1702e31dbc2aebe7762451552c4efaad660cbe166a5d4e88e0c25fc431970aa4519e94864a9e54b8c548d65c724831
|
7
|
+
data.tar.gz: b0b0375281dd5900fe8f328c61d4efb895b13e7965d645a1d551df1afa09144749056ea0e43424732208da5ec0e5a7f2209d685f5851cf9761d0e47662002abf
|
data/.rubocop.yml
CHANGED
data/isodoc.gemspec
CHANGED
@@ -26,8 +26,10 @@ Gem::Specification.new do |spec|
|
|
26
26
|
f.match(%r{^(test|spec|features|bin|.github)/}) \
|
27
27
|
|| f.match(%r{Rakefile|bin/rspec})
|
28
28
|
end
|
29
|
-
spec.required_ruby_version = Gem::Requirement.new(">=
|
29
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 3.1.0")
|
30
30
|
|
31
|
+
spec.add_dependency "base64"
|
32
|
+
spec.add_dependency "bigdecimal"
|
31
33
|
spec.add_dependency "html2doc", "~> 1.8.1"
|
32
34
|
# spec.add_dependency "isodoc-i18n", "~> 1.1.0" # already in relaton-render and mn-requirements
|
33
35
|
# spec.add_dependency "relaton-cli"
|
@@ -12,12 +12,12 @@ $('#toggle').on('click', function(){
|
|
12
12
|
$('nav').animate({ 'left': '-353px' }, 'slow', function(){
|
13
13
|
$('nav').hide();
|
14
14
|
});
|
15
|
-
$('body').animate({ '
|
15
|
+
$('body').animate({ 'padding-left': '30px' }, 'slow');
|
16
16
|
}
|
17
17
|
else {
|
18
18
|
$('nav').show();
|
19
19
|
$('nav').animate({ 'left': '0px' }, 'slow');
|
20
|
-
$('body').animate({ '
|
20
|
+
$('body').animate({ 'padding-left': '360px' }, 'slow');
|
21
21
|
}
|
22
22
|
});
|
23
23
|
</script>
|
data/lib/isodoc/class_utils.rb
CHANGED
@@ -8,7 +8,10 @@ module IsoDoc
|
|
8
8
|
|
9
9
|
def mathml(docxml)
|
10
10
|
docxml.xpath("//m:math", MATHML).each { |f| mathml_linebreak(f) }
|
11
|
-
locale =
|
11
|
+
locale = @lang.to_sym
|
12
|
+
@numfmt = Plurimath::NumberFormatter
|
13
|
+
.new(locale, localize_number: @localizenumber,
|
14
|
+
localizer_symbols: twitter_cldr_localiser_symbols)
|
12
15
|
docxml.xpath("//m:math", MATHML).each do |f| # rubocop:disable Style/CombinableLoops
|
13
16
|
mathml1(f, locale)
|
14
17
|
end
|
@@ -18,75 +21,88 @@ module IsoDoc
|
|
18
21
|
# TwitterCldr::DataReaders::NumberDataReader.new(locale).symbols
|
19
22
|
def localize_maths(node, locale)
|
20
23
|
node.xpath(".//m:mn", MATHML).each do |x|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
+
x.children =
|
25
|
+
if fmt = x["data-metanorma-numberformat"]
|
26
|
+
x.delete("data-metanorma-numberformat")
|
27
|
+
explicit_number_formatter(x, locale, fmt)
|
28
|
+
else implicit_number_formatter(x, locale)
|
29
|
+
end
|
24
30
|
rescue ArgumentError
|
31
|
+
rescue Error => e
|
32
|
+
warn "Failure to localised MathML/mn\n#{node.parent.to_xml}\n#{e}"
|
25
33
|
end
|
26
34
|
end
|
27
35
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
return localized unless twitter_cldr_reader_symbols[:decimal]
|
34
|
-
|
35
|
-
integer, fraction = localized.split(twitter_cldr_reader_symbols[:decimal])
|
36
|
-
return localized if fraction.nil? || fraction.empty?
|
36
|
+
def normalise_number(num)
|
37
|
+
n = BigDecimal(num).to_s("F")
|
38
|
+
/\.\d/.match?(num) or n.sub!(/\.\d+$/, "")
|
39
|
+
n
|
40
|
+
end
|
37
41
|
|
38
|
-
|
39
|
-
|
42
|
+
def implicit_number_formatter(num, locale)
|
43
|
+
fmt = { digit_count: num_totaldigits(num.text) }.compact
|
44
|
+
n = normalise_number(num.text)
|
45
|
+
# Plurimath confused by exponent notation
|
46
|
+
#warn "IMPLICIT: precision: #{num_precision(num.text)} ; symbols: #{fmt}, n: #{n}; output: #{@numfmt.localized_number(n, locale:, format: fmt, precision: num_precision(num.text))}"
|
47
|
+
@numfmt.localized_number(n, locale:, format: fmt,
|
48
|
+
precision: num_precision(num.text))
|
40
49
|
end
|
41
50
|
|
42
|
-
def
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
51
|
+
def numberformat_extract(options)
|
52
|
+
options.gsub!(/([a-z_]+)='/, %('\\1=))
|
53
|
+
CSV.parse_line(options, quote_char: "'").each_with_object({}) do |x, acc|
|
54
|
+
m = /^(.+?)=(.+)?$/.match(x) or next
|
55
|
+
acc[m[1].to_sym] = m[2].sub(/^(["'])(.+)\1$/, "\\2")
|
47
56
|
end
|
48
57
|
end
|
49
58
|
|
50
|
-
def
|
51
|
-
|
52
|
-
|
53
|
-
fract = fract.slice(0..(twitter_cldr_reader_symbols[:precision] || -1))
|
54
|
-
fr_group_digits = twitter_cldr_reader_symbols[:fraction_group_digits] || 1
|
55
|
-
until fract.empty?
|
56
|
-
result.push(fract.slice!(0, fr_group_digits))
|
59
|
+
def numberformat_type(ret)
|
60
|
+
%i(precision digit_count group_digits fraction_group_digits).each do |i|
|
61
|
+
ret[i] &&= ret[i].to_i
|
57
62
|
end
|
58
|
-
|
63
|
+
%i(notation exponent_sign locale).each do |i|
|
64
|
+
ret[i] &&= ret[i].to_sym
|
65
|
+
end
|
66
|
+
ret
|
59
67
|
end
|
60
68
|
|
61
|
-
def
|
62
|
-
|
69
|
+
def explicit_number_formatter(num, locale, options)
|
70
|
+
ret = numberformat_type(numberformat_extract(options))
|
71
|
+
l = ret[:locale] || locale
|
72
|
+
precision, symbols, digit_count = explicit_number_formatter_cfg(num, ret)
|
73
|
+
n = normalise_number(num.text)
|
74
|
+
# Plurimath confused by exponent notation
|
75
|
+
#warn "EXPLICIT: precision: #{precision} ; symbols: #{symbols}, n: #{n}; output: #{Plurimath::NumberFormatter.new(l, localizer_symbols: symbols).localized_number(n, precision:, format: symbols.merge(digit_count:))}"
|
76
|
+
Plurimath::NumberFormatter.new(l, localizer_symbols: symbols)
|
77
|
+
.localized_number(n, precision:,
|
78
|
+
format: symbols.merge(digit_count:))
|
63
79
|
end
|
64
80
|
|
65
|
-
def
|
66
|
-
|
81
|
+
def explicit_number_formatter_cfg(num, fmt)
|
82
|
+
symbols = twitter_cldr_localiser_symbols.dup.merge(fmt)
|
83
|
+
precision = symbols[:precision]&.to_i || num_precision(num.text)
|
84
|
+
symbols[:precision] or digit_count = num_totaldigits(num.text)
|
85
|
+
[precision, symbols, digit_count]
|
86
|
+
end
|
67
87
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
88
|
+
def num_precision(num)
|
89
|
+
precision = nil
|
90
|
+
/\.(?!\d+e)/.match?(num) and
|
91
|
+
precision = twitter_cldr_localiser_symbols[:precision] ||
|
92
|
+
num.sub(/^.*\./, "").size
|
93
|
+
precision
|
72
94
|
end
|
73
95
|
|
74
|
-
def
|
75
|
-
|
76
|
-
|
77
|
-
|
96
|
+
def num_totaldigits(num)
|
97
|
+
totaldigits = nil
|
98
|
+
/\.(?=\d+e)/.match?(num) and
|
99
|
+
totaldigits = twitter_cldr_localiser_symbols[:digit_count] ||
|
100
|
+
num.sub(/^.*\./, "").sub(/e.*$/, "").size
|
101
|
+
totaldigits
|
78
102
|
end
|
79
103
|
|
80
|
-
def
|
81
|
-
|
82
|
-
m = %r{(?<grp>[^#])?(?<grpdig>#+0)(?<decpt>.)(?<frdig>#+)(?<frgrp>[^#])?}
|
83
|
-
.match(@localizenumber) or return {}
|
84
|
-
ret = { decimal: m[:decpt], group_digits: m[:grpdig].size,
|
85
|
-
fraction_group_digits: m[:frdig].size,
|
86
|
-
group: m[:grp] || "",
|
87
|
-
fraction_group: m[:frgrp] || "" }.compact
|
88
|
-
%i(group fraction_group).each { |x| ret[x] == " " and ret[x] = "\u00A0" }
|
89
|
-
ret
|
104
|
+
def twitter_cldr_localiser_symbols
|
105
|
+
{}
|
90
106
|
end
|
91
107
|
|
92
108
|
def asciimath_dup(node)
|
@@ -20,7 +20,7 @@ module IsoDoc
|
|
20
20
|
|
21
21
|
def convert1(docxml, filename, dir)
|
22
22
|
@outputdir = dir
|
23
|
-
@outputfile = filename
|
23
|
+
@outputfile = Pathname.new(filename).basename.to_s
|
24
24
|
docid_prefixes(docxml) # feeds @xrefs.parse citation processing
|
25
25
|
@xrefs.parse docxml
|
26
26
|
@xrefs.klass.meta = @meta
|
data/lib/isodoc/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isodoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.10.
|
4
|
+
version: 2.10.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: base64
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bigdecimal
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: html2doc
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -418,7 +446,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
418
446
|
requirements:
|
419
447
|
- - ">="
|
420
448
|
- !ruby/object:Gem::Version
|
421
|
-
version:
|
449
|
+
version: 3.1.0
|
422
450
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
423
451
|
requirements:
|
424
452
|
- - ">="
|