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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d57eb699105f5f1b40c5b31cf51259a1bd60b458ac2b6ab0326beaa915c63750
4
- data.tar.gz: 99b2d95988e2f1bb989f0779a60298c57fe08e69127bc07f063bd813403e5858
3
+ metadata.gz: 82d1c3ed71a05f100f76c7e3ff42ec7fd4fe27c2a018bb312a2639f27d69e8b1
4
+ data.tar.gz: b170bf5e893fb25d9506d34b7ee725c19cf7778270b724f3697a7ac56a487a98
5
5
  SHA512:
6
- metadata.gz: 5657c1f981918049eab6e6cd2d17d9d929309714025936dc27256f4ce0ec6b04b3c60a8bbd8839daec8eb322515425349cba06972ef888706ed44ea886cd8527
7
- data.tar.gz: 1129bf0dbb9d6e31ef5a8fc50d2dd1f63aa70658c4ffdc60329c6e60fd6da3ffb7127fb32c99609ddd68da4b703f8712f0487820362081d1752d2ac983f5b079
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>
@@ -67,7 +67,7 @@ module IsoDoc
67
67
 
68
68
  def nearest_block_parent(node)
69
69
  until %w(p title td th name formula li dt dd sourcecode pre quote
70
- note example)
70
+ note example target clause annex term appendix bibdata)
71
71
  .include?(node.name)
72
72
  node = node.parent
73
73
  end
@@ -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 = twitter_cldr_localiser
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
- num = BigDecimal(x.text)
22
- precision = /\./.match?(x.text) ? x.text.sub(/^.*\./, "").size : 0
23
- x.children = localized_number(num, locale, precision)
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
- # By itself twitter-cldr does not support fraction part digits grouping
29
- # and custom delimeter, will decorate fraction part manually
30
- def localized_number(num, locale, precision)
31
- localized = localized_number1(num, locale, precision)
32
- twitter_cldr_reader_symbols = twitter_cldr_reader(locale)
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
- [integer, decorate_fraction_part(fraction, locale)]
39
- .join(twitter_cldr_reader_symbols[:decimal])
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 localized_number1(num, locale, precision)
43
- if precision.zero?
44
- num.localize(locale).to_s
45
- else
46
- num.localize(locale).to_decimal.to_s(precision: precision)
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 decorate_fraction_part(fract, locale)
51
- result = []
52
- twitter_cldr_reader_symbols = twitter_cldr_reader(locale)
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
- result.join(twitter_cldr_reader_symbols[:fraction_group].to_s)
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 twitter_cldr_localiser_symbols
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 twitter_cldr_reader(locale)
66
- return @twitter_cldr_reader if @twitter_cldr_reader
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
- num = TwitterCldr::DataReaders::NumberDataReader.new(locale)
69
- @twitter_cldr_reader = num.symbols.merge!(twitter_cldr_localiser_symbols)
70
- .merge!(parse_localize_number)
71
- @twitter_cldr_reader
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 twitter_cldr_localiser
75
- locale = TwitterCldr.supported_locale?(@lang.to_sym) ? @lang.to_sym : :en
76
- twitter_cldr_reader(locale)
77
- locale
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 parse_localize_number
81
- @localizenumber or return {}
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
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "2.10.3".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.3
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-03 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
  - - ">="