metanorma-iso 3.2.1 → 3.2.3

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.
@@ -19,7 +19,7 @@ module IsoDoc
19
19
  id = elem["bibitemid"] or return
20
20
  b = @bibitem_lookup[id] or return
21
21
  b["type"] != "standard" ||
22
- !b.at(ns("./docidentifier[not(@type = 'metanorma' or @type = 'metanorma-ordinal')]"))
22
+ !b.at(ns("./docidentifier[not(@type = 'metanorma' or @type = 'metanorma-ordinal' or @type='author-date')]"))
23
23
  end
24
24
 
25
25
  # style [1] references as [Reference 1], eref or origin
@@ -147,6 +147,11 @@ 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 anchor_xref(node, target, container: false)
152
+ #require "debug"; binding.b
153
+ super
154
+ end
150
155
  end
151
156
  end
152
157
  end
@@ -30,28 +30,40 @@ module IsoDoc
30
30
  clause.at(ns("./clause")) and
31
31
  @anchors[clause["id"]] = { label: nil, level: 1, type: "clause",
32
32
  xref: clause.at(ns("./title"))&.text }
33
- i = clause_counter(0)
34
- clause.xpath(ns("./clause")).each do |c|
33
+ clause.xpath(ns("./clause"))
34
+ .each_with_object(clause_counter(0)) do |c, i|
35
35
  section_names1(c, semx(clause, "0"), i.increment(c).print, 2)
36
36
  end
37
37
  end
38
38
 
39
- # subclauses are not prefixed with "Clause"
40
- # retaining subtype for the semantics
41
39
  def section_name_anchors(clause, num, level)
42
40
  if clause["type"] == "section"
43
- xref = labelled_autonum(@labels["section"], num)
44
- label = labelled_autonum(@labels["section"], num)
45
- @anchors[clause["id"]] =
46
- { label:, xref:, elem: @labels["section"],
47
- title: clause_title(clause), level: level, type: "clause" }
41
+ section_name_anchors_section(clause, num, level)
48
42
  elsif level > 1
49
- @anchors[clause["id"]] =
50
- { label: num, level: level, xref: num, subtype: "clause" }
51
- else super
43
+ section_name_anchors_subclause(clause, num, level)
44
+ else
45
+ super
52
46
  end
53
47
  end
54
48
 
49
+ def section_name_anchors_section(clause, num, level)
50
+ xref = labelled_autonum(@labels["section"], num)
51
+ label = labelled_autonum(@labels["section"], num)
52
+ @anchors[clause["id"]] =
53
+ { label:, xref:, elem: @labels["section"],
54
+ title: clause_title(clause), level: level, type: "clause" }
55
+ end
56
+
57
+ # subclauses are not prefixed with "Clause" but @labels["subclause"],
58
+ # which in ISO is "" (but in inheriting flavors/tastes may be "Subclause")
59
+ # Retaining subtype for the semantics
60
+ def section_name_anchors_subclause(clause, num, level)
61
+ xref = labelled_autonum(@labels["subclause"], num)
62
+ @anchors[clause["id"]] =
63
+ { label: num, level: level, xref:, subtype: "clause",
64
+ title: subclause_title(clause), elem: @labels["subclause"] }
65
+ end
66
+
55
67
  def annex_name_anchors1(clause, num, level)
56
68
  level == 1 and return annex_name_anchors(clause, num, level)
57
69
  ret = { label: num, level: level, subtype: "annex" }
@@ -63,6 +75,15 @@ module IsoDoc
63
75
  end
64
76
  @anchors[clause["id"]] = ret.merge(ret2)
65
77
  end
78
+
79
+ def subclause_title(clause, use_elem_name: false)
80
+ ret = clause.at(ns("./title"))&.text
81
+ if use_elem_name && ret.blank?
82
+ @i18n.labels["subclause"]&.capitalize
83
+ else
84
+ clause_title(clause, use_elem_name: use_elem_name)
85
+ end
86
+ end
66
87
  end
67
88
  end
68
89
  end
@@ -466,11 +466,11 @@ Editorial and advisory groups are represented as consecutive subdivisions of the
466
466
  <a:documentation>Contact information for the organization, including address, phone number, and email</a:documentation>
467
467
  </ref>
468
468
  </optional>
469
- <optional>
469
+ <zeroOrMore>
470
470
  <ref name="logo">
471
471
  <a:documentation>A logo for the organization</a:documentation>
472
472
  </ref>
473
- </optional>
473
+ </zeroOrMore>
474
474
  </define>
475
475
  <define name="orgname">
476
476
  <element name="name">
@@ -502,6 +502,11 @@ Editorial and advisory groups are represented as consecutive subdivisions of the
502
502
  </define>
503
503
  <define name="logo">
504
504
  <element name="logo">
505
+ <optional>
506
+ <attribute name="type">
507
+ <a:documentation>The type of logo</a:documentation>
508
+ </attribute>
509
+ </optional>
505
510
  <ref name="image-no-id"/>
506
511
  </element>
507
512
  </define>
@@ -513,6 +518,11 @@ Editorial and advisory groups are represented as consecutive subdivisions of the
513
518
  <a:documentation>Description of what is being depicted</a:documentation>
514
519
  </attribute>
515
520
  </optional>
521
+ <optional>
522
+ <attribute name="type">
523
+ <a:documentation>Description of what kind of depiction this</a:documentation>
524
+ </attribute>
525
+ </optional>
516
526
  <zeroOrMore>
517
527
  <ref name="image-no-id">
518
528
  <a:documentation>A visual depiction of the bibliographic item</a:documentation>
@@ -1236,9 +1246,9 @@ Refer to `BibliographicItem` for definitions</a:documentation>
1236
1246
  <optional>
1237
1247
  <ref name="validity"/>
1238
1248
  </optional>
1239
- <optional>
1249
+ <zeroOrMore>
1240
1250
  <ref name="depiction"/>
1241
- </optional>
1251
+ </zeroOrMore>
1242
1252
  </define>
1243
1253
  <define name="btitle">
1244
1254
  <a:documentation>A title of a bibliographic item, associated with a type of title</a:documentation>
@@ -34,7 +34,8 @@ module Metanorma
34
34
  id = iso_id_default(iso_id_params(node))
35
35
  id.stage or return
36
36
  if abbr = id.typed_stage_abbrev
37
- abbr = abbr.to_s.upcase.strip
37
+ # remove IS: work around breakages in pubid-iso
38
+ abbr = abbr.to_s.upcase.strip.sub(/^IS /, "")
38
39
  end
39
40
  xml.stagename metadata_stagename(id)&.strip,
40
41
  **attr_code(abbreviation: abbr)
@@ -125,6 +125,7 @@ module Metanorma
125
125
  if stage && !cen?(node.attr("publisher"))
126
126
  ret[:stage] = stage
127
127
  ret[:stage] == "60.00" and ret[:stage] = :PRF
128
+ #ret[:stage] == "60.60" and ret[:stage] = nil
128
129
  end
129
130
  ret
130
131
  end
@@ -160,6 +161,7 @@ module Metanorma
160
161
  @amd and return
161
162
  iso_id_out_non_amd(xml, params, with_prf)
162
163
  rescue StandardError, *STAGE_ERROR => e
164
+ @log.add("ISO_52", "Document identifier: #{e}")
163
165
  clean_abort("Document identifier: #{e}", xml)
164
166
  end
165
167
 
@@ -170,10 +172,11 @@ module Metanorma
170
172
  end
171
173
 
172
174
  def iso_id_out_common(xml, params, with_prf)
175
+ params1 = skip_60_60(params)
173
176
  add_noko_elem(xml, "docidentifier",
174
- iso_id_default(params).to_s(with_prf:),
177
+ iso_id_default(params1).to_s(with_prf:),
175
178
  **attr_code(type: "ISO", primary: "true"))
176
- add_noko_elem(xml, "docidentifier", iso_id_reference(params)
179
+ add_noko_elem(xml, "docidentifier", iso_id_reference(params1)
177
180
  .to_s(format: :ref_num_short, with_prf:),
178
181
  **attr_code(type: "iso-reference"))
179
182
  add_noko_elem(xml, "docidentifier", iso_id_reference(params).urn,
@@ -181,14 +184,23 @@ module Metanorma
181
184
  end
182
185
 
183
186
  def iso_id_out_non_amd(xml, params, with_prf)
187
+ params1 = skip_60_60(params)
184
188
  add_noko_elem(xml, "docidentifier",
185
- iso_id_undated(params).to_s(with_prf:),
189
+ iso_id_undated(params1).to_s(with_prf:),
186
190
  **attr_code(type: "iso-undated"))
187
191
  add_noko_elem(xml, "docidentifier",
188
- iso_id_with_lang(params).to_s(format: :ref_num_long, with_prf:),
192
+ iso_id_with_lang(params1).to_s(format: :ref_num_long, with_prf:),
189
193
  **attr_code(type: "iso-with-lang"))
190
194
  end
191
195
 
196
+ # work around breakages in pubid-iso
197
+ def skip_60_60(params)
198
+ ret = params.dup
199
+ ret[:stage] == "60.60" and ret[:stage] = nil
200
+ warn ret
201
+ ret
202
+ end
203
+
192
204
  def iso_id_default(params)
193
205
  params_nolang = params.dup.tap { |hs| hs.delete(:language) }
194
206
  params1 = params_nolang
@@ -217,12 +229,11 @@ module Metanorma
217
229
  end
218
230
 
219
231
  def structured_id(node, xml)
220
- node.attr("docnumber") or return
232
+ node.attr("docnumber") or return # allow empty node.attr("docnumber")
221
233
  part, subpart = node.attr("partnumber")&.split("-")
222
234
  xml.structuredidentifier do |i|
223
- add_noko_elem(i, "project-number", node.attr("docnumber"), **attr_code(
224
- part:, subpart:,
225
- amendment: node.attr("amendment-number"),
235
+ i.project_number(node.attr("docnumber"), **attr_code(
236
+ part:, subpart:, amendment: node.attr("amendment-number"),
226
237
  corrigendum: node.attr("corrigendum-number"),
227
238
  addendum: node.attr("addendum-number"),
228
239
  origyr: node.attr("created-date")
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
- <!-- VERSION v2.1.4 -->
3
+ <!-- VERSION v2.1.5 -->
4
4
 
5
5
  <!--
6
6
  ALERT: cannot have root comments, because of https://github.com/metanorma/metanorma/issues/437
@@ -137,6 +137,9 @@ module Metanorma
137
137
  "ISO_51": { category: "Style",
138
138
  error: "non-terms clauses cannot cross-reference terms clause (%s)",
139
139
  severity: 2 },
140
+ "ISO_52": { category: "Style",
141
+ error: "non-terms clauses cannot cross-reference terms clause (%s)",
142
+ severity: 0 },
140
143
  }.freeze
141
144
  # rubocop:enable Naming/VariableNumber
142
145
 
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Iso
3
- VERSION = "3.2.1".freeze
3
+ VERSION = "3.2.3".freeze
4
4
  end
5
5
  end
@@ -0,0 +1,43 @@
1
+ module Relaton
2
+ module Render
3
+ module Template
4
+ module SelectiveCapitalize
5
+ def selective_capitalize(input, exceptions)
6
+ return nil if input.nil?
7
+
8
+ # Convert exceptions to an array if it's not already
9
+ exceptions_array = exceptions.is_a?(Array) ? exceptions : [exceptions]
10
+
11
+ # Split the input into words
12
+ words = input.split(/\s+/)
13
+
14
+ # Capitalize each word unless it's in the exceptions list
15
+ words.map do |word|
16
+ if exceptions_array.include?(word.downcase)
17
+ word
18
+ else
19
+ word.capitalize
20
+ end
21
+ end.join(' ')
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ # Extend the customise_liquid method to register our filter
29
+ module Relaton
30
+ module Render
31
+ module Template
32
+ class General
33
+ alias_method :original_customise_liquid, :customise_liquid
34
+
35
+ def customise_liquid
36
+ original_customise_liquid
37
+ # Register our filter
38
+ ::Liquid::Template.register_filter(::Relaton::Render::Template::SelectiveCapitalize)
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -35,8 +35,12 @@ Gem::Specification.new do |spec|
35
35
  spec.add_dependency "metanorma-standoc", "~> 3.2.0"
36
36
  spec.add_dependency "mnconvert", "~> 1.14"
37
37
  spec.add_dependency "pubid"
38
+ #spec.add_dependency "pubid-cen"
39
+ #spec.add_dependency "pubid-iec"
40
+ #spec.add_dependency "pubid-iso", "~> 0.7.0"
38
41
  spec.add_dependency "tokenizer", "~> 0.3.0"
39
42
 
43
+ spec.add_development_dependency "canon", "= 0.1.3"
40
44
  spec.add_development_dependency "debug"
41
45
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
42
46
  spec.add_development_dependency "guard", "~> 2.14"
@@ -46,10 +50,9 @@ Gem::Specification.new do |spec|
46
50
  spec.add_development_dependency "rake", "~> 13.0"
47
51
  spec.add_development_dependency "rspec", "~> 3.6"
48
52
  spec.add_development_dependency "rubocop", "~> 1"
49
- spec.add_development_dependency "rubocop-performance"
53
+ spec.add_development_dependency "rubocop-performance"
50
54
  spec.add_development_dependency "sassc-embedded", "~> 1"
51
55
  spec.add_development_dependency "simplecov", "~> 0.15"
52
56
  spec.add_development_dependency "timecop", "~> 0.9"
53
57
  spec.add_development_dependency "webmock"
54
- spec.add_development_dependency "canon", "= 0.1.3"
55
58
  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.2.1
4
+ version: 3.2.3
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-11-17 00:00:00.000000000 Z
11
+ date: 2025-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-standoc
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.3.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: canon
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 0.1.3
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 0.1.3
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: debug
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -262,20 +276,6 @@ dependencies:
262
276
  - - ">="
263
277
  - !ruby/object:Gem::Version
264
278
  version: '0'
265
- - !ruby/object:Gem::Dependency
266
- name: canon
267
- requirement: !ruby/object:Gem::Requirement
268
- requirements:
269
- - - '='
270
- - !ruby/object:Gem::Version
271
- version: 0.1.3
272
- type: :development
273
- prerelease: false
274
- version_requirements: !ruby/object:Gem::Requirement
275
- requirements:
276
- - - '='
277
- - !ruby/object:Gem::Version
278
- version: 0.1.3
279
279
  description: |
280
280
  metanorma-iso lets you write ISO standards in AsciiDoc syntax.
281
281
 
@@ -405,6 +405,7 @@ files:
405
405
  - lib/relaton/render/config.yml
406
406
  - lib/relaton/render/general.rb
407
407
  - lib/relaton/render/parse.rb
408
+ - lib/relaton/render/selective_capitalize.rb
408
409
  - metanorma-iso.gemspec
409
410
  homepage: https://github.com/metanorma/metanorma-iso
410
411
  licenses: