isodoc 2.10.3 → 2.10.4

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: df0cc3b9722ac37d5d0853fe0b483fedc476ad51655488a893dcb7c58f08b5a3
4
+ data.tar.gz: 8f5fe80aa471b64d274e3c8b44b87cc6c9fd5ff20bf52b9a61ee3d8ede5421e0
5
5
  SHA512:
6
- metadata.gz: 5657c1f981918049eab6e6cd2d17d9d929309714025936dc27256f4ce0ec6b04b3c60a8bbd8839daec8eb322515425349cba06972ef888706ed44ea886cd8527
7
- data.tar.gz: 1129bf0dbb9d6e31ef5a8fc50d2dd1f63aa70658c4ffdc60329c6e60fd6da3ffb7127fb32c99609ddd68da4b703f8712f0487820362081d1752d2ac983f5b079
6
+ metadata.gz: 2f8da1dc68e54da5f58af3ad2ca370e175cc914216ecd2148068ec745975c8229371fa87b586ab60c4701b0b21d9b676893e15d97cabc1e513cba20c5ed2ad80
7
+ data.tar.gz: b20e85c69fe1f89c327b22c2f0232ab751c577028de077bb6b890ae337d24c98de939a8ecb1ff8607a6d2dd9e577abec8404372572033361c4939578be4e0c99
@@ -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,77 +21,25 @@ 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 = @numfmt
25
+ .localized_number(x.text, locale: locale,
26
+ precision: num_precision(x.text))
24
27
  rescue ArgumentError
25
28
  end
26
29
  end
27
30
 
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?
37
-
38
- [integer, decorate_fraction_part(fraction, locale)]
39
- .join(twitter_cldr_reader_symbols[:decimal])
40
- end
41
-
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)
47
- end
48
- end
49
-
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))
57
- end
58
- result.join(twitter_cldr_reader_symbols[:fraction_group].to_s)
31
+ def num_precision(num)
32
+ precision = 0
33
+ /\./.match?(num) and precision =
34
+ twitter_cldr_localiser_symbols[:precision] ||
35
+ num.sub(/^.*\./, "").size
36
+ precision
59
37
  end
60
38
 
61
39
  def twitter_cldr_localiser_symbols
62
40
  {}
63
41
  end
64
42
 
65
- def twitter_cldr_reader(locale)
66
- return @twitter_cldr_reader if @twitter_cldr_reader
67
-
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
72
- end
73
-
74
- def twitter_cldr_localiser
75
- locale = TwitterCldr.supported_locale?(@lang.to_sym) ? @lang.to_sym : :en
76
- twitter_cldr_reader(locale)
77
- locale
78
- end
79
-
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
90
- end
91
-
92
43
  def asciimath_dup(node)
93
44
  @suppressasciimathdup || node.parent.at(ns("./asciimath")) and return
94
45
  math = node.to_xml.gsub(/ xmlns=["'][^"']+["']/, "")
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "2.10.3".freeze
2
+ VERSION = "2.10.4".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
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.4
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-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: html2doc