metanorma-iso 3.1.5 → 3.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -51,12 +51,12 @@ module IsoDoc
51
51
  end
52
52
 
53
53
  def subclause?(target, type, from)
54
- (from&.match?(/\./) && type == "clause") ||
54
+ (from&.include?(".") && type == "clause") ||
55
55
  type == "list" ||
56
56
  target&.gsub(/<[^<>]+>/, "")&.match(/^IEV$|^IEC 60050-/)
57
57
  end
58
58
 
59
- # ISO has not bothered to communicate to us what most of these
59
+ # ISO has not bothered to communicate to us what most of these
60
60
  # span classes mean
61
61
  LOCALITY2SPAN = {
62
62
  annex: "citeapp",
@@ -83,8 +83,8 @@ module IsoDoc
83
83
  end
84
84
 
85
85
  def eref_localities1_zh(opt)
86
- ret = " 第#{opt[:from]}" if opt[:from]
87
- ret += "&#x2013;#{opt[:upto]}" if opt[:upto]
86
+ ret = " 第<esc>#{opt[:from]}</esc>" if opt[:from]
87
+ ret += "&#x2013;<esc>#{opt[:upto]}</esc>" if opt[:upto]
88
88
  opt[:node]["droploc"] != "true" &&
89
89
  !subclause?(opt[:target], opt[:type], opt[:from]) and
90
90
  ret += eref_locality_populate(opt[:type], opt[:node], "sg")
@@ -93,10 +93,10 @@ module IsoDoc
93
93
  end
94
94
 
95
95
  def eref_localities1(opt)
96
- return nil if opt[:type] == "anchor"
97
-
96
+ opt[:type] == "anchor" and return nil
98
97
  opt[:type] = opt[:type].downcase
99
- opt[:lang] == "zh" and return l10n(eref_localities1_zh(opt))
98
+ %w(zh ko ja).include?(opt[:lang]) and
99
+ return l10n(eref_localities1_zh(opt))
100
100
  ret = ""
101
101
  opt[:node]["droploc"] != "true" &&
102
102
  !subclause?(opt[:target], opt[:type], opt[:from]) and
@@ -117,8 +117,8 @@ module IsoDoc
117
117
  container_label = prefix_container(container_container,
118
118
  container_label, node, target)
119
119
  l10n(connectives_spans(nested_xref
120
- .sub("%1", "<span class='fmt-xref-container'>#{container_label}</span>")
121
- .sub("%2", linkend)))
120
+ .sub("%1", "<span class='fmt-xref-container'><esc>#{container_label}</esc></span>")
121
+ .sub("%2", "<esc>#{linkend}</esc>")))
122
122
  end
123
123
 
124
124
  def prefix_container_template(container, node, target)
@@ -147,6 +147,77 @@ module IsoDoc
147
147
  locality_span_wrap(super, @xrefs.anchor(node["target"], :subtype) ||
148
148
  @xrefs.anchor(node["target"], :type))
149
149
  end
150
+
151
+ def origin(docxml)
152
+ super
153
+ bracketed_refs_processing(docxml)
154
+ end
155
+
156
+ # style [1] references as [Reference 1], eref or origin
157
+ def bracketed_refs_processing(docxml)
158
+ (docxml.xpath(ns("//semx[@element = 'eref']")) -
159
+ docxml.xpath(ns("//semx[@element = 'erefstack']//semx[@element = 'eref']")))
160
+ .each { |n| bracket_eref_style(n) }
161
+ docxml.xpath(ns("//semx[@element = 'erefstack']")).each do |n|
162
+ bracket_erefstack_style(n)
163
+ end
164
+ docxml.xpath(ns("//semx[@element = 'origin']")).each do |n|
165
+ bracket_origin_style(n)
166
+ end
167
+ end
168
+
169
+ def bracket_eref_style(elem)
170
+ semx = bracket_eref_original(elem) or return
171
+ if semx["style"] == "superscript"
172
+ elem.children.wrap("<sup></sup>")
173
+ remove_preceding_space(elem)
174
+ else
175
+ r = @i18n.reference
176
+ elem.add_first_child l10n("#{r} ")
177
+ end
178
+ end
179
+
180
+ # is the eref corresponding to this semx a simple [n] reference?
181
+ def bracket_eref_original(elem)
182
+ semx = elem.document.at("//*[@id = '#{elem['source']}']") or return
183
+ non_locality_elems(semx).empty? or return
184
+ /^\[\d+\]$/.match?(semx["citeas"]) or return
185
+ semx
186
+ end
187
+
188
+ def bracket_erefstack_style(elem)
189
+ semx, erefstack_orig = bracket_erefstack_style_prep(elem)
190
+ semx.empty? and return
191
+ if erefstack_orig && erefstack_orig["style"]
192
+ elem.children.each do |e|
193
+ e.name == "span" and e.remove
194
+ e.text.strip.empty? and e.remove
195
+ end
196
+ elem.children.wrap("<sup></sup>")
197
+ remove_preceding_space(elem)
198
+ else
199
+ r = @i18n.inflect(@i18n.reference, number: "pl")
200
+ elem.add_first_child l10n("#{r} ")
201
+ end
202
+ end
203
+
204
+ def bracket_erefstack_style_prep(elem)
205
+ semx = elem.xpath(ns(".//semx[@element = 'eref']"))
206
+ .map { |e| bracket_eref_original(e) }.compact
207
+ erefstack_orig = elem.document.at("//*[@id = '#{elem['source']}']")
208
+ [semx, erefstack_orig]
209
+ end
210
+
211
+ def bracket_origin_style(elem)
212
+ bracket_eref_style(elem)
213
+ end
214
+
215
+ def remove_preceding_space(elem)
216
+ # Find the preceding text node that has actual content
217
+ prec = elem.at("./preceding-sibling::text()" \
218
+ "[normalize-space(.) != ''][1]") or return
219
+ prec.content.end_with?(" ") and prec.content = prec.content.rstrip
220
+ end
150
221
  end
151
222
  end
152
223
  end
@@ -169,7 +169,7 @@ module IsoDoc
169
169
 
170
170
  def termref_parse(node, out)
171
171
  out.p **termref_attrs do |p|
172
- node.children.each { |n| parse(n, p) }
172
+ children_parse(node, p)
173
173
  end
174
174
  end
175
175
 
@@ -181,7 +181,7 @@ module IsoDoc
181
181
  def figure_name_parse(node, div, name)
182
182
  name.nil? and return
183
183
  div.p **figure_name_attrs(node) do |p|
184
- name.children.each { |n| parse(n, p) }
184
+ children_parse(name, p)
185
185
  end
186
186
  end
187
187
 
@@ -193,7 +193,7 @@ module IsoDoc
193
193
  def table_title_parse(node, out)
194
194
  name = node.at(ns("./fmt-name")) or return
195
195
  out.p **table_title_attrs(node) do |p|
196
- name&.children&.each { |n| parse(n, p) }
196
+ children_parse(name, p)
197
197
  end
198
198
  end
199
199
 
@@ -82,10 +82,11 @@ module IsoDoc
82
82
  )
83
83
  if elem["unnumbered"] != "true"
84
84
  # Dropping the parent figure label is specific to ISO
85
+ p = elem.at("./ancestor::xmlns:figure")
85
86
  @anchors[elem["id"]][:label] = sublabel
86
- @anchors[elem["id"]][:xref] = @anchors[elem.parent["id"]][:xref] +
87
+ @anchors[elem["id"]][:xref] = @anchors[p["id"]][:xref] +
87
88
  " " + semx(elem, sublabel) + delim_wrap(subfigure_delim)
88
- x = @anchors[elem.parent["id"]][:container] and
89
+ x = @anchors[p["id"]][:container] and
89
90
  @anchors[elem["id"]][:container] = x
90
91
  end
91
92
  end
@@ -158,7 +159,6 @@ module IsoDoc
158
159
  s.xpath(ns(".//appendix//ol")) - s.xpath(ns(".//ol//ol"))
159
160
  c = Counter.new
160
161
  notes.noblank.each do |n|
161
- # n["id"] ||= "_#{UUIDTools::UUID.random_create}"
162
162
  @anchors[n["id"]] = anchor_struct(increment_label(notes, n, c), n,
163
163
  @labels["list"], "list",
164
164
  { unnumb: false, container: true })
@@ -203,12 +203,11 @@ module IsoDoc
203
203
  end
204
204
 
205
205
  def xref_to_modspec(id, table_label)
206
- # (@anchors[id] && !@anchors[id][:has_modspec]) or return
207
206
  (@anchors[id] && !@anchors[id][:has_table_prefix]) or return
208
207
  @anchors[id][:has_table_prefix] = true
209
208
  x = @anchors_previous[id][:xref_bare] || @anchors_previous[id][:xref]
210
- @anchors[id][:xref] = l10n(@klass.connectives_spans(@i18n.nested_xref
211
- .sub("%1", table_label).sub("%2", x)))
209
+ @anchors[id][:xref] = @klass.connectives_spans(@i18n.nested_xref
210
+ .sub("%1", table_label).sub("%2", x))
212
211
  @anchors[id][:modspec] = @anchors_previous[id][:modspec]
213
212
  @anchors[id][:subtype] = "modspec" # prevents citetbl style from beign applied
214
213
  true
@@ -244,6 +243,15 @@ module IsoDoc
244
243
  { unnum: false, container: true })
245
244
  end
246
245
  end
246
+
247
+ def sequential_permission_body(id, parent_id, elem, label, klass, model,
248
+ container: false)
249
+ e = elem["id"] || elem["original-id"]
250
+ has_table_prefix = @anchors.dig(e, :has_table_prefix)
251
+ has_table_prefix and return
252
+ super
253
+ #has_table_prefix and @anchors[e][:has_table_prefix] = true # restore
254
+ end
247
255
  end
248
256
  end
249
257
  end
@@ -23,7 +23,6 @@ module IsoDoc
23
23
  { label:, xref:, elem: @labels["section"],
24
24
  title: clause_title(clause), level: level, type: "clause" }
25
25
  elsif level > 1
26
- #num = semx(clause, num)
27
26
  @anchors[clause["id"]] =
28
27
  { label: num, level: level, xref: num, subtype: "clause" }
29
28
  else super end
@@ -34,8 +33,7 @@ module IsoDoc
34
33
  ret = { label: num, level: level, subtype: "annex" }
35
34
  ret2 = if level == 2
36
35
  xref = labelled_autonum(@labels["clause"], num)
37
- { xref:, # l10n("#{@labels['clause']} #{num}"),
38
- elem: @labels["clause"] }
36
+ { xref:, elem: @labels["clause"] }
39
37
  else
40
38
  { xref: semx(clause, num) }
41
39
  end
@@ -869,7 +869,7 @@ depending on whether the items exist as independent documents, or are parts of a
869
869
  </zeroOrMore>
870
870
  </element>
871
871
  </define>
872
- <define name="BibItemType" combine="choice">
872
+ <define name="BibItemType">
873
873
  <a:documentation>Type of bibliographic item.
874
874
  The value list complies with the types provided in ISO 690:2021.
875
875
  NOTE: These values represent a strict superset to BibTeX
@@ -311,17 +311,28 @@ and is intended to be referenced by a callout within the source code</a:document
311
311
  </ref>
312
312
  </optional>
313
313
  <choice>
314
- <a:documentation>Content of the figure</a:documentation>
315
- <ref name="image"/>
314
+ <a:documentation>Content of the figure </a:documentation>
315
+ <ref name="image">
316
+ <a:documentation>by default the content of a figure is a media file</a:documentation>
317
+ </ref>
316
318
  <ref name="video"/>
317
319
  <ref name="audio"/>
318
- <ref name="pre"/>
320
+ <ref name="pre">
321
+ <a:documentation>figures can contain ASCII art</a:documentation>
322
+ </ref>
319
323
  <oneOrMore>
320
- <ref name="paragraph-with-footnote"/>
324
+ <ref name="paragraph-with-footnote">
325
+ <a:documentation>figures can contain discursive art</a:documentation>
326
+ </ref>
321
327
  </oneOrMore>
322
328
  <zeroOrMore>
323
- <ref name="figure"/>
329
+ <ref name="figure">
330
+ <a:documentation>subfigures, nested directly within a figure</a:documentation>
331
+ </ref>
324
332
  </zeroOrMore>
333
+ <ref name="table">
334
+ <a:documentation>Table is understood in this context to be a tabular arrangement of subfigures</a:documentation>
335
+ </ref>
325
336
  </choice>
326
337
  <zeroOrMore>
327
338
  <ref name="fn">
@@ -354,17 +365,28 @@ and is intended to be referenced by a callout within the source code</a:document
354
365
  </ref>
355
366
  </optional>
356
367
  <choice>
357
- <a:documentation>Content of the figure</a:documentation>
358
- <ref name="image-no-id"/>
368
+ <a:documentation>Content of the figure </a:documentation>
369
+ <ref name="image-no-id">
370
+ <a:documentation>by default the content of a figure is a media file</a:documentation>
371
+ </ref>
359
372
  <ref name="video-no-id"/>
360
373
  <ref name="audio-no-id"/>
361
- <ref name="pre-no-id"/>
374
+ <ref name="pre-no-id">
375
+ <a:documentation>figures can contain ASCII art</a:documentation>
376
+ </ref>
362
377
  <oneOrMore>
363
- <ref name="paragraph-with-footnote-no-id"/>
378
+ <ref name="paragraph-with-footnote-no-id">
379
+ <a:documentation>figures can contain discursive art</a:documentation>
380
+ </ref>
364
381
  </oneOrMore>
365
382
  <zeroOrMore>
366
- <ref name="figure-no-id"/>
383
+ <ref name="figure-no-id">
384
+ <a:documentation>subfigures, nested directly within a figure</a:documentation>
385
+ </ref>
367
386
  </zeroOrMore>
387
+ <ref name="table-no-id">
388
+ <a:documentation>Table is understood in this context to be a tabular arrangement of subfigures</a:documentation>
389
+ </ref>
368
390
  </choice>
369
391
  <zeroOrMore>
370
392
  <ref name="fn">
@@ -876,6 +898,9 @@ titlecase, or lowercase</a:documentation>
876
898
  <data type="boolean"/>
877
899
  </attribute>
878
900
  </optional>
901
+ <ref name="LocalizedStringAttributes">
902
+ <a:documentation>Specify language of bibitem, can be used to render it with language-specific bibliographic style</a:documentation>
903
+ </ref>
879
904
  <ref name="ReducedBibliographicItem"/>
880
905
  </element>
881
906
  </define>
@@ -86,7 +86,7 @@ module Metanorma
86
86
  end
87
87
 
88
88
  def list_semicolon_phrase_punct(elem, text, last)
89
- punct = text.strip.sub(/^.*?(\S)$/m, "\\1")
89
+ punct = text.strip.sub(/^.*?(\S)\z/m, "\\1")
90
90
  if last
91
91
  punct == "." or
92
92
  style_warning(elem, "Final list entry of broken up " \
@@ -105,7 +105,7 @@ module Metanorma
105
105
  starts_uppercase?(text) or
106
106
  style_warning(elem, "List entry of separate sentences must start " \
107
107
  "with uppercase letter", text, display: false)
108
- punct = text.strip.sub(/^.*?(\S)$/m, "\\1")
108
+ punct = text.strip.sub(/^.*?(\S)\z/m, "\\1")
109
109
  punct == "." or
110
110
  style_warning(elem, "List entry of separate sentences must " \
111
111
  "end with full stop", text, display: false)
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Iso
3
- VERSION = "3.1.5".freeze
3
+ VERSION = "3.1.7".freeze
4
4
  end
5
5
  end
@@ -50,5 +50,5 @@ spec.add_development_dependency "rubocop-performance"
50
50
  spec.add_development_dependency "simplecov", "~> 0.15"
51
51
  spec.add_development_dependency "timecop", "~> 0.9"
52
52
  spec.add_development_dependency "webmock"
53
- spec.add_development_dependency "canon"
53
+ spec.add_development_dependency "canon", "= 0.1.3"
54
54
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-iso
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.5
4
+ version: 3.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-09-15 00:00:00.000000000 Z
11
+ date: 2025-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-standoc
@@ -252,16 +252,16 @@ dependencies:
252
252
  name: canon
253
253
  requirement: !ruby/object:Gem::Requirement
254
254
  requirements:
255
- - - ">="
255
+ - - '='
256
256
  - !ruby/object:Gem::Version
257
- version: '0'
257
+ version: 0.1.3
258
258
  type: :development
259
259
  prerelease: false
260
260
  version_requirements: !ruby/object:Gem::Requirement
261
261
  requirements:
262
- - - ">="
262
+ - - '='
263
263
  - !ruby/object:Gem::Version
264
- version: '0'
264
+ version: 0.1.3
265
265
  description: |
266
266
  metanorma-iso lets you write ISO standards in AsciiDoc syntax.
267
267