isodoc 2.11.3 → 2.12.0

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: 4228f130d19273b278dcf701d27c405d37a7843b053eed057b424af2d7399b09
4
- data.tar.gz: 003b627868c9e53ae1eb6baf7f9cb71a06a3e3e0c09b6102cd5e1dc7c45faee5
3
+ metadata.gz: f7b57ce9e119a72a5611931503d20a6a6eb525b9f07cbc06b0e8794a80db8da2
4
+ data.tar.gz: 51a4d399f9ab8b7730a08d15deaa52b0526efbbe27cea41e355fca92ce0768ba
5
5
  SHA512:
6
- metadata.gz: 2e865cfbe5a51e7a78a1562b7d88b7930a0eacf8db22e94c0e4ed0dc12f7c76b75975c98296a0f1624c82d729fdc03a5715f01237a14b68fa8b612a17f297a49
7
- data.tar.gz: 533d41c63cf5955bc60f7223716cfea1151d959d0cdec32577154159c88abe4d9c0d81b2c8256fccc3e1b02d2e59dd8dcff613dee425f64ce417e390b77e3fe2
6
+ metadata.gz: 280cf748d5411c671d3e9f7d6e4b949611f1567766bddcdea160b5eff1bf49d6b61df5b706092f0775812515fb78ccf4812edfb79a98f47d0bcfef9e6215fe70
7
+ data.tar.gz: 3af9ba5dec2db7b37542f8dab65bc90cdf19f1298110fc230aac03187814c88bffeed194d3d9de7a2e1892f82767d24cab970f780a3655985dfa7f0482d851d1
@@ -75,6 +75,9 @@ p kbd, dt kbd, li kbd, label kbd, legend kbd, caption kbd, th kbd, td kbd,
75
75
  p samp, dt samp, li samp, label samp, legend samp, caption samp, th samp, td samp {
76
76
  font-size: {{monospacefontsize}}; }
77
77
 
78
+ sub, sup {
79
+ font-size: 0.75em; }
80
+
78
81
  article, aside, details, figcaption, figure,
79
82
  footer, header, hgroup, menu, nav, section {
80
83
  display: block; }
@@ -75,6 +75,9 @@ p kbd, dt kbd, li kbd, label kbd, legend kbd, caption kbd, th kbd, td kbd,
75
75
  p samp, dt samp, li samp, label samp, legend samp, caption samp, th samp, td samp {
76
76
  font-size: {{monospacefontsize}}; }
77
77
 
78
+ sub, sup {
79
+ font-size: 0.75em; }
80
+
78
81
  article, aside, details, figcaption, figure,
79
82
  footer, header, hgroup, menu, nav, section {
80
83
  display: block; }
@@ -81,6 +81,10 @@ p samp, dt samp, li samp, label samp, legend samp, caption samp, th samp, td sam
81
81
  font-size: $monospacefontsize;
82
82
  }
83
83
 
84
+ sub, sup {
85
+ font-size: 0.75em;
86
+ }
87
+
84
88
  article, aside, details, figcaption, figure,
85
89
  footer, header, hgroup, menu, nav, section {
86
90
  display: block;
@@ -15,7 +15,7 @@ module IsoDoc
15
15
 
16
16
  def initialize(lang, script, locale, i18n, fonts_options = {})
17
17
  @metadata = { lang:, script: }
18
- DATETYPES.each { |w| @metadata["#{w.gsub('-', '_')}date".to_sym] = "XXX" }
18
+ DATETYPES.each { |w| @metadata["#{w.tr('-', '_')}date".to_sym] = "XXX" }
19
19
  @lang = lang
20
20
  @script = script
21
21
  @locale = locale
@@ -21,9 +21,10 @@ 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
+ fmt = x["data-metanorma-numberformat"]
25
+ x.delete("data-metanorma-numberformat")
24
26
  x.children =
25
- if fmt = x["data-metanorma-numberformat"]
26
- x.delete("data-metanorma-numberformat")
27
+ if !fmt.nil? && !fmt.empty?
27
28
  explicit_number_formatter(x, locale, fmt)
28
29
  else implicit_number_formatter(x, locale)
29
30
  end
@@ -61,7 +62,7 @@ module IsoDoc
61
62
  .each do |i|
62
63
  ret[i] &&= ret[i].to_i
63
64
  end
64
- %i(notation exponent_sign locale).each do |i|
65
+ %i(notation exponent_sign number_sign locale).each do |i|
65
66
  ret[i] &&= ret[i].to_sym
66
67
  end
67
68
  ret
@@ -78,12 +79,39 @@ module IsoDoc
78
79
  end
79
80
 
80
81
  def explicit_number_formatter_cfg(num, fmt)
81
- symbols = twitter_cldr_localiser_symbols.dup.merge(fmt)
82
- precision = symbols[:precision] || num_precision(num.text)
82
+ symbols = twitter_cldr_localiser_symbols.dup.transform_values do |v|
83
+ v.is_a?(String) ? HTMLEntities.new.decode(v) : v
84
+ end.merge(fmt)
85
+ symbols = large_notation_fmt(symbols, num.text)
86
+ [symbols[:precision] || num_precision(num.text), symbols,
87
+ explicit_number_formatter_signif(num, symbols)]
88
+ end
89
+
90
+ def explicit_number_formatter_signif(num, symbols)
83
91
  signif = symbols[:significant]
84
92
  (symbols.keys & %i(precision digit_count)).empty? and
85
93
  signif ||= num_totaldigits(num.text)
86
- [precision, symbols, signif]
94
+ signif
95
+ end
96
+
97
+ def large_notation_fmt(symbols, num)
98
+ n = symbols[:large_notation]
99
+ min = BigDecimal(symbols[:large_notation_min] || "1e-6")
100
+ max = BigDecimal(symbols[:large_notation_max] || "1e6")
101
+ n1 = large_notation_fmt1(num, n, min, max) and symbols[:notation] = n1
102
+ symbols.delete(:large_notation)
103
+ symbols.delete(:large_notation_min)
104
+ symbols.delete(:large_notation_max)
105
+ symbols
106
+ end
107
+
108
+ def large_notation_fmt1(num, notation, min, max)
109
+ notation.nil? || notation == "nil" and return nil
110
+ val = BigDecimal(num).abs
111
+ val.zero? and return nil
112
+ val < min and return notation
113
+ val > max and return notation
114
+ nil
87
115
  end
88
116
 
89
117
  def num_precision(num)
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "2.11.3".freeze
2
+ VERSION = "2.12.0".freeze
3
3
  end
@@ -64,7 +64,6 @@ module IsoDoc
64
64
  'span[@style="MsoCommentReference"]'.freeze
65
65
 
66
66
  def embed_comment_in_comment_list(docxml)
67
- # docxml.xpath(COMMENT_IN_COMMENT_LIST).each do |x|
68
67
  docxml.xpath(COMMENT_IN_COMMENT_LIST1).each do |x|
69
68
  n = x.next_element
70
69
  n&.children&.first&.add_previous_sibling(x.remove)
@@ -31,7 +31,7 @@ module IsoDoc
31
31
 
32
32
  def anchor_struct_label(lbl, elem)
33
33
  case elem
34
- when @labels["appendix"] then l10n("#{elem} #{lbl}")
34
+ when @labels["appendix"] then "#{elem} #{lbl}"
35
35
  else
36
36
  lbl.to_s
37
37
  end
@@ -1,4 +1,5 @@
1
1
  require "roman-numerals"
2
+ require "twitter_cldr"
2
3
 
3
4
  module IsoDoc
4
5
  module XrefGen
@@ -26,6 +27,7 @@ module IsoDoc
26
27
  @style = opts[:numerals]
27
28
  @skip_i = opts[:skip_i]
28
29
  @prefix = opts[:prefix]
30
+ @separator = opts[:separator] || "."
29
31
  @base = ""
30
32
  if num.is_a? String
31
33
  if /^\d+$/.match?(num)
@@ -139,7 +141,8 @@ module IsoDoc
139
141
  end
140
142
 
141
143
  def increment(node)
142
- @unnumbered = node["unnumbered"] == "true" || node["hidden"] == "true" and return self
144
+ @unnumbered = node["unnumbered"] == "true" ||
145
+ node["hidden"] == "true" and return self
143
146
  reset_overrides
144
147
  if node["subsequence"] != @subseq &&
145
148
  !(blank?(node["subsequence"]) && blank?(@subseq))
@@ -150,12 +153,23 @@ module IsoDoc
150
153
  self
151
154
  end
152
155
 
156
+ def style_number(num)
157
+ num.nil? and return num
158
+ case @style
159
+ when :roman then RomanNumerals.to_roman(num)
160
+ when :japanese then num.localize(:ja).spellout
161
+ else num
162
+ end
163
+ end
164
+
153
165
  def print
154
166
  @unnumbered and return nil
155
167
  @prefix_override and return @prefix_override
156
168
  num = @number_override || @num
157
- out = @style == :roman && !num.nil? ? RomanNumerals.to_roman(num) : num
158
- "#{@prefix}#{@base}#{out}#{@letter_override || @letter}"
169
+ out = style_number(num)
170
+ prefix = @prefix
171
+ prefix &&= "#{prefix}#{@separator}"
172
+ "#{prefix}#{@base}#{out}#{@letter_override || @letter}"
159
173
  end
160
174
 
161
175
  def ol_type(list, depth)
@@ -176,6 +190,7 @@ module IsoDoc
176
190
  when :alphabet_upper then (64 + @num).chr.to_s
177
191
  when :roman then RomanNumerals.to_roman(@num).downcase
178
192
  when :roman_upper then RomanNumerals.to_roman(@num).upcase
193
+ when :japanese then num.localize(:ja).spellout
179
194
  end
180
195
  end
181
196
  end
@@ -0,0 +1,13 @@
1
+ require_relative "xref_counter"
2
+
3
+ module IsoDoc
4
+ class Xref
5
+ def clause_counter(num = 0, opts = { numerals: :arabic })
6
+ ::IsoDoc::XrefGen::Counter.new(num, opts)
7
+ end
8
+
9
+ def list_counter(num = 0, opts = { numerals: :arabic })
10
+ ::IsoDoc::XrefGen::Counter.new(num, opts)
11
+ end
12
+ end
13
+ end
@@ -33,8 +33,7 @@ module IsoDoc
33
33
  end
34
34
 
35
35
  def increment_label(elems, node, counter, increment: true)
36
- return "" if elems.size == 1 && !node["number"]
37
-
36
+ elems.size == 1 && !node["number"] and return ""
38
37
  counter.increment(node) if increment
39
38
  " #{counter.print}"
40
39
  end
@@ -48,7 +47,7 @@ module IsoDoc
48
47
  { label: termnote_label(c.print), type: "termnote",
49
48
  value: c.print, elem: @labels["termnote"],
50
49
  container: t["id"],
51
- xref: l10n("#{@labels['note_xref']} #{c.print}") }
50
+ xref: "#{@labels['note_xref']} #{c.print}" }
52
51
  end
53
52
  end
54
53
  end
@@ -64,7 +63,7 @@ module IsoDoc
64
63
  { label: idx, type: "termexample",
65
64
  value: idx, elem: @labels["example_xref"],
66
65
  container: t["id"],
67
- xref: l10n("#{@labels['example_xref']} #{idx}") }
66
+ xref: "#{@labels['example_xref']} #{idx}" }
68
67
  end
69
68
  end
70
69
  end
@@ -123,7 +122,7 @@ module IsoDoc
123
122
  sections.each do |s|
124
123
  notes = s.xpath(ns(".//ol")) - s.xpath(ns(".//clause//ol")) -
125
124
  s.xpath(ns(".//appendix//ol")) - s.xpath(ns(".//ol//ol"))
126
- c = Counter.new
125
+ c = list_counter
127
126
  notes.noblank.each do |n|
128
127
  @anchors[n["id"]] = anchor_struct(increment_label(notes, n, c), n,
129
128
  @labels["list"], "list", false)
@@ -134,7 +133,7 @@ module IsoDoc
134
133
  end
135
134
 
136
135
  def list_item_anchor_names(list, list_anchor, depth, prev_label, refer_list)
137
- c = Counter.new(list["start"] ? list["start"].to_i - 1 : 0)
136
+ c = list_counter(list["start"] ? list["start"].to_i - 1 : 0)
138
137
  list.xpath(ns("./li")).each do |li|
139
138
  bare_label, label =
140
139
  list_item_value(li, c, depth, { list_anchor:, prev_label:,
@@ -188,7 +187,7 @@ module IsoDoc
188
187
 
189
188
  def deflist_term_anchor_names(list, list_anchor)
190
189
  list.xpath(ns("./dt")).each do |li|
191
- label = l10n("#{list_anchor[:xref]}: #{dt2xreflabel(li)}")
190
+ label = "#{list_anchor[:xref]}: #{dt2xreflabel(li)}"
192
191
  li["id"] and @anchors[li["id"]] =
193
192
  { xref: label, type: "deflistitem",
194
193
  container: list_anchor[:container] }
@@ -66,7 +66,7 @@ module IsoDoc
66
66
  def sequential_table_names(clause, container: false)
67
67
  c = Counter.new
68
68
  clause.xpath(ns(".//table")).noblank.each do |t|
69
- labelled_ancestor(t) and next
69
+ # labelled_ancestor(t) and next
70
70
  @anchors[t["id"]] = anchor_struct(
71
71
  c.increment(t).print, container ? t : nil,
72
72
  @labels["table"], "table", t["unnumbered"]
@@ -190,7 +190,7 @@ container: false)
190
190
  def hierarchical_table_names(clause, num)
191
191
  c = Counter.new
192
192
  clause.xpath(ns(".//table")).noblank.each do |t|
193
- labelled_ancestor(t) and next
193
+ # labelled_ancestor(t) and next
194
194
  @anchors[t["id"]] =
195
195
  anchor_struct("#{num}#{hiersep}#{c.increment(t).print}",
196
196
  nil, @labels["table"], "table", t["unnumbered"])
@@ -56,7 +56,7 @@ module IsoDoc
56
56
  end
57
57
 
58
58
  def main_anchor_names(xml)
59
- n = Counter.new
59
+ n = clause_counter
60
60
  clause_order_main(xml).each do |a|
61
61
  xml.xpath(ns(a[:path])).each do |c|
62
62
  section_names(c, n, 1)
@@ -144,7 +144,7 @@ module IsoDoc
144
144
  num.increment(clause)
145
145
  section_name_anchors(clause, num.print, lvl)
146
146
  clause.xpath(ns(SUBCLAUSES))
147
- .each_with_object(Counter.new(0, prefix: "#{num.print}.")) do |c, i|
147
+ .each_with_object(clause_counter(0, prefix: num.print)) do |c, i|
148
148
  section_names1(c, i.increment(c).print, lvl + 1)
149
149
  end
150
150
  num
@@ -153,7 +153,7 @@ module IsoDoc
153
153
  def section_names1(clause, num, level)
154
154
  unnumbered_section_name?(clause) and return num
155
155
  section_name_anchors(clause, num, level)
156
- i = Counter.new(0, prefix: "#{num}.")
156
+ i = clause_counter(0, prefix: num)
157
157
  clause.xpath(ns(SUBCLAUSES)).each do |c|
158
158
  section_names1(c, i.increment(c).print, level + 1)
159
159
  end
@@ -170,18 +170,18 @@ module IsoDoc
170
170
 
171
171
  def section_name_anchors(clause, num, level)
172
172
  @anchors[clause["id"]] =
173
- { label: num, xref: l10n("#{@labels['clause']} #{num}"),
173
+ { label: num, xref: "#{@labels['clause']} #{num}",
174
174
  title: clause_title(clause), level:, type: "clause",
175
175
  elem: @labels["clause"] }
176
176
  end
177
177
 
178
178
  def annex_name_lbl(clause, num)
179
- obl = l10n("(#{@labels['inform_annex']})")
179
+ obl = "(#{@labels['inform_annex']})"
180
180
  clause["obligation"] == "normative" and
181
- obl = l10n("(#{@labels['norm_annex']})")
181
+ obl = "(#{@labels['norm_annex']})"
182
182
  title = Common::case_with_markup(@labels["annex"], "capital",
183
183
  @script)
184
- l10n("<strong>#{title} #{num}</strong><br/>#{obl}")
184
+ "<strong>#{title} #{num}</strong><br/>#{obl}"
185
185
  end
186
186
 
187
187
  def annex_name_anchors(clause, num, level)
@@ -203,7 +203,7 @@ module IsoDoc
203
203
  num.to_s, 1)
204
204
  else
205
205
  clause.xpath(ns(SUBCLAUSES))
206
- .each_with_object(Counter.new(0, prefix: "#{num}.")) do |c, i|
206
+ .each_with_object(clause_counter(0, prefix: num)) do |c, i|
207
207
  annex_names1(c, i.increment(c).print, 2)
208
208
  end
209
209
  end
@@ -212,7 +212,7 @@ module IsoDoc
212
212
 
213
213
  def annex_names1(clause, num, level)
214
214
  annex_name_anchors(clause, num, level)
215
- i = Counter.new(0, prefix: "#{num}.")
215
+ i = clause_counter(0, prefix: num)
216
216
  clause.xpath(ns(SUBCLAUSES)).each do |c|
217
217
  annex_names1(c, i.increment(c).print, level + 1)
218
218
  end
data/lib/isodoc/xref.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require_relative "xref/xref_anchor"
2
2
  require_relative "xref/xref_counter"
3
+ require_relative "xref/xref_counter_types"
3
4
  require_relative "xref/xref_gen_seq"
4
5
  require_relative "xref/xref_gen"
5
6
  require_relative "xref/xref_sect_gen"
@@ -17,25 +18,31 @@ module IsoDoc
17
18
 
18
19
  # Note: if bibrender is no passed in, do not parse references
19
20
  def initialize(lang, script, klass, i18n, options = {})
20
- @anchors = {}
21
+ initialize_empty
21
22
  @lang = lang
22
23
  @script = script
23
24
  @klass = klass
24
25
  @options = options
25
- @i18n = i18n
26
- @labels = @i18n.get
27
- @klass.i18n = @i18n
26
+ initialize_i18n(i18n)
28
27
  @klass.bibrender ||= options[:bibrender]
29
- @locale = options[:locale]
30
28
  @reqt_models = @klass.requirements_processor
31
- .new({
32
- default: "default", lang:, script:,
33
- labels: @i18n.get
34
- })
35
- @i18n
29
+ .new({ default: "default", lang:, script:,
30
+ labels: @i18n.get })
31
+ end
32
+
33
+ def initialize_empty
34
+ @c = HTMLEntities.new
35
+ @anchors = {}
36
36
  @parse_settings = {}
37
37
  end
38
38
 
39
+ def initialize_i18n(i18n)
40
+ @i18n = i18n
41
+ @labels = @i18n.get
42
+ @klass.i18n = @i18n
43
+ @locale = @options[:locale]
44
+ end
45
+
39
46
  def get
40
47
  @anchors
41
48
  end
@@ -66,9 +73,18 @@ module IsoDoc
66
73
  initial_anchor_names(docxml)
67
74
  back_anchor_names(docxml)
68
75
  asset_anchor_names(docxml)
76
+ localise_anchors
69
77
  @parse_settings = {}
70
78
  end
71
79
 
80
+ def localise_anchors
81
+ @anchors.each_value do |v|
82
+ v[:label] &&= l10n(v[:label])
83
+ v[:value] &&= l10n(v[:value])
84
+ v[:xref] &&= l10n(v[:xref])
85
+ end
86
+ end
87
+
72
88
  def ns(xpath)
73
89
  Common::ns(xpath)
74
90
  end
@@ -96,18 +96,18 @@ version: version
96
96
  toc_figures: List of figures
97
97
  toc_tables: List of tables
98
98
  toc_recommendations: List of recommendations
99
- month_january: January
100
- month_february: February
101
- month_march: March
102
- month_april: April
103
- month_may: May
104
- month_june: June
105
- month_july: July
106
- month_august: August
107
- month_september: September
108
- month_october: October
109
- month_november: November
110
- month_december: December
99
+ month_january: 1月
100
+ month_february: 2月
101
+ month_march: 3月
102
+ month_april: 4月
103
+ month_may: 5月
104
+ month_june: 6月
105
+ month_july: 7月
106
+ month_august: 8月
107
+ month_september: 9月
108
+ month_october: 10月
109
+ month_november: 11月
110
+ month_december: 12月
111
111
  obligation: Obligation
112
112
  admonition: {
113
113
  danger: 危険です,
@@ -118,7 +118,7 @@ admonition: {
118
118
  editorial: 編集者注
119
119
  }
120
120
  locality: {
121
- section: Section,
121
+ section: セクション,
122
122
  clause: 箇条,
123
123
  subclause: 細分箇条,
124
124
  part: 部,
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.11.3
4
+ version: 2.12.0
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-09-16 00:00:00.000000000 Z
11
+ date: 2024-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -451,6 +451,7 @@ files:
451
451
  - lib/isodoc/xref/clause_order.rb
452
452
  - lib/isodoc/xref/xref_anchor.rb
453
453
  - lib/isodoc/xref/xref_counter.rb
454
+ - lib/isodoc/xref/xref_counter_types.rb
454
455
  - lib/isodoc/xref/xref_gen.rb
455
456
  - lib/isodoc/xref/xref_gen_seq.rb
456
457
  - lib/isodoc/xref/xref_sect_gen.rb