isodoc 2.10.4 → 2.10.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df0cc3b9722ac37d5d0853fe0b483fedc476ad51655488a893dcb7c58f08b5a3
4
- data.tar.gz: 8f5fe80aa471b64d274e3c8b44b87cc6c9fd5ff20bf52b9a61ee3d8ede5421e0
3
+ metadata.gz: 82d1c3ed71a05f100f76c7e3ff42ec7fd4fe27c2a018bb312a2639f27d69e8b1
4
+ data.tar.gz: b170bf5e893fb25d9506d34b7ee725c19cf7778270b724f3697a7ac56a487a98
5
5
  SHA512:
6
- metadata.gz: 2f8da1dc68e54da5f58af3ad2ca370e175cc914216ecd2148068ec745975c8229371fa87b586ab60c4701b0b21d9b676893e15d97cabc1e513cba20c5ed2ad80
7
- data.tar.gz: b20e85c69fe1f89c327b22c2f0232ab751c577028de077bb6b890ae337d24c98de939a8ecb1ff8607a6d2dd9e577abec8404372572033361c4939578be4e0c99
6
+ metadata.gz: ca60c3933004e3b6b5ebcf1864baf52ebe1702e31dbc2aebe7762451552c4efaad660cbe166a5d4e88e0c25fc431970aa4519e94864a9e54b8c548d65c724831
7
+ data.tar.gz: b0b0375281dd5900fe8f328c61d4efb895b13e7965d645a1d551df1afa09144749056ea0e43424732208da5ec0e5a7f2209d685f5851cf9761d0e47662002abf
data/.rubocop.yml CHANGED
@@ -7,4 +7,4 @@ inherit_from:
7
7
  # ...
8
8
 
9
9
  AllCops:
10
- TargetRubyVersion: 2.5
10
+ TargetRubyVersion: 3.4
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(">= 2.7.0")
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({ 'margin-left': '0' }, 'slow');
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({ 'margin-left': '298px' }, 'slow');
20
+ $('body').animate({ 'padding-left': '360px' }, 'slow');
21
21
  }
22
22
  });
23
23
  </script>
@@ -21,21 +21,86 @@ module IsoDoc
21
21
  # TwitterCldr::DataReaders::NumberDataReader.new(locale).symbols
22
22
  def localize_maths(node, locale)
23
23
  node.xpath(".//m:mn", MATHML).each do |x|
24
- x.children = @numfmt
25
- .localized_number(x.text, locale: locale,
26
- precision: num_precision(x.text))
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
27
30
  rescue ArgumentError
31
+ rescue Error => e
32
+ warn "Failure to localised MathML/mn\n#{node.parent.to_xml}\n#{e}"
28
33
  end
29
34
  end
30
35
 
36
+ def normalise_number(num)
37
+ n = BigDecimal(num).to_s("F")
38
+ /\.\d/.match?(num) or n.sub!(/\.\d+$/, "")
39
+ n
40
+ end
41
+
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))
49
+ end
50
+
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")
56
+ end
57
+ end
58
+
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
62
+ end
63
+ %i(notation exponent_sign locale).each do |i|
64
+ ret[i] &&= ret[i].to_sym
65
+ end
66
+ ret
67
+ end
68
+
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:))
79
+ end
80
+
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
87
+
31
88
  def num_precision(num)
32
- precision = 0
33
- /\./.match?(num) and precision =
34
- twitter_cldr_localiser_symbols[:precision] ||
35
- num.sub(/^.*\./, "").size
89
+ precision = nil
90
+ /\.(?!\d+e)/.match?(num) and
91
+ precision = twitter_cldr_localiser_symbols[:precision] ||
92
+ num.sub(/^.*\./, "").size
36
93
  precision
37
94
  end
38
95
 
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
102
+ end
103
+
39
104
  def twitter_cldr_localiser_symbols
40
105
  {}
41
106
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "2.10.4".freeze
2
+ VERSION = "2.10.5".freeze
3
3
  end
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
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-06-17 00:00:00.000000000 Z
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: 2.7.0
449
+ version: 3.1.0
422
450
  required_rubygems_version: !ruby/object:Gem::Requirement
423
451
  requirements:
424
452
  - - ">="