metanorma-iso 2.9.2 → 2.9.4

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.
@@ -1,6 +1,5 @@
1
1
  require_relative "init"
2
2
  require "isodoc"
3
- require_relative "index"
4
3
  require_relative "presentation_xref"
5
4
  require_relative "presentation_bibdata"
6
5
  require_relative "presentation_terms"
@@ -298,6 +297,10 @@ module IsoDoc
298
297
  end
299
298
  end
300
299
 
300
+ def enable_indexsect
301
+ true
302
+ end
303
+
301
304
  include Init
302
305
  end
303
306
  end
@@ -267,11 +267,11 @@ Detailed in https://www.relaton.org/model/creator/</a:documentation>
267
267
  <a:documentation>An identifier of the person according to an international identifier scheme</a:documentation>
268
268
  </ref>
269
269
  </zeroOrMore>
270
- <zeroOrMore>
270
+ <optional>
271
271
  <ref name="contact">
272
272
  <a:documentation>Contact information for the person, including URI, address, phone number, and email</a:documentation>
273
273
  </ref>
274
- </zeroOrMore>
274
+ </optional>
275
275
  </element>
276
276
  </define>
277
277
  <define name="fullname">
@@ -454,11 +454,11 @@ real names (if the person is named with a pseudonym or user name); previous lega
454
454
  <a:documentation>An identifier of the organization according to an international identifier scheme</a:documentation>
455
455
  </ref>
456
456
  </zeroOrMore>
457
- <zeroOrMore>
457
+ <optional>
458
458
  <ref name="contact">
459
459
  <a:documentation>Contact information for the organization, including address, phone number, and email</a:documentation>
460
460
  </ref>
461
- </zeroOrMore>
461
+ </optional>
462
462
  <optional>
463
463
  <ref name="logo">
464
464
  <a:documentation>A logo for the organization</a:documentation>
@@ -540,12 +540,18 @@ real names (if the person is named with a pseudonym or user name); previous lega
540
540
  <!-- TODO may change -->
541
541
  <define name="contact">
542
542
  <a:documentation>Contact information for a person or organization</a:documentation>
543
- <choice>
543
+ <zeroOrMore>
544
544
  <ref name="address"/>
545
+ </zeroOrMore>
546
+ <zeroOrMore>
545
547
  <ref name="phone"/>
548
+ </zeroOrMore>
549
+ <zeroOrMore>
546
550
  <ref name="email"/>
551
+ </zeroOrMore>
552
+ <zeroOrMore>
547
553
  <ref name="uri"/>
548
- </choice>
554
+ </zeroOrMore>
549
555
  </define>
550
556
  <define name="phone">
551
557
  <a:documentation>The phone number associated with a person or organization</a:documentation>
@@ -22,6 +22,7 @@ module Metanorma
22
22
  xml.updates_document_type a
23
23
  a = node.attr("fast-track") and xml.send "fast-track", a != "false"
24
24
  a = node.attr("price-code") and xml.price_code a
25
+ node.attr("iso-cen-parallel") and xml.iso_cen_parallel true
25
26
  end
26
27
 
27
28
  STAGE_ERROR = [Pubid::Core::Errors::HarmonizedStageCodeInvalidError,
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Iso
3
- VERSION = "2.9.2".freeze
3
+ VERSION = "2.9.4".freeze
4
4
  end
5
5
  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: 2.9.2
4
+ version: 2.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-10 00:00:00.000000000 Z
11
+ date: 2025-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-standoc
@@ -331,7 +331,6 @@ files:
331
331
  - lib/isodoc/iso/i18n-ru.yaml
332
332
  - lib/isodoc/iso/i18n-zh-Hans.yaml
333
333
  - lib/isodoc/iso/i18n.rb
334
- - lib/isodoc/iso/index.rb
335
334
  - lib/isodoc/iso/init.rb
336
335
  - lib/isodoc/iso/iso.amendment.xsl
337
336
  - lib/isodoc/iso/iso.international-standard.xsl
@@ -393,7 +392,7 @@ homepage: https://github.com/metanorma/metanorma-iso
393
392
  licenses:
394
393
  - BSD-2-Clause
395
394
  metadata: {}
396
- post_install_message:
395
+ post_install_message:
397
396
  rdoc_options: []
398
397
  require_paths:
399
398
  - lib
@@ -409,7 +408,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
409
408
  version: '0'
410
409
  requirements: []
411
410
  rubygems_version: 3.3.27
412
- signing_key:
411
+ signing_key:
413
412
  specification_version: 4
414
413
  summary: metanorma-iso lets you write ISO standards in AsciiDoc.
415
414
  test_files: []
@@ -1,173 +0,0 @@
1
- module IsoDoc
2
- module Iso
3
- class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
4
- def add_id
5
- %(id="_#{UUIDTools::UUID.random_create}")
6
- end
7
-
8
- def index(xml)
9
- if xml.at(ns("//index"))
10
- i = xml.at(ns("//indexsect")) ||
11
- xml.root.add_child("<indexsect #{add_id}><title>#{@i18n.index}" \
12
- "</title></indexsect>").first
13
- index = sort_indexterms(xml.xpath(ns("//index")),
14
- xml.xpath(ns("//index-xref[@also = 'false']")),
15
- xml.xpath(ns("//index-xref[@also = 'true']")))
16
- index1(xml, i, index)
17
- else xml.xpath(ns("//indexsect")).each(&:remove)
18
- end
19
- end
20
-
21
- def index1(docxml, indexsect, index)
22
- c = indexsect.add_child("<ul></ul>").first
23
- index.keys.sort.each do |k|
24
- words = index[k].keys.each_with_object({}) do |w, v|
25
- v[sortable(w).downcase] = w
26
- end
27
- words.keys.localize(@lang.to_sym).sort.to_a.each do |w|
28
- c.add_child index_entries(words, index[k], w)
29
- end
30
- end
31
- index1_cleanup(docxml)
32
- end
33
-
34
- def index1_cleanup(docxml)
35
- docxml.xpath(ns("//indexsect//xref")).each do |x|
36
- x.children.remove
37
- end
38
- @xrefs.bookmark_anchor_names(docxml)
39
- end
40
-
41
- def sortable(str)
42
- HTMLEntities.new.decode(Nokogiri::XML.fragment(str).text)
43
- end
44
-
45
- def index_entries_opt
46
- { xref_lbl: ", ", see_lbl: ", #{see_lbl}", also_lbl: ", #{also_lbl}" }
47
- end
48
-
49
- def index_entries(words, index, primary)
50
- ret = index_entries_head(words[primary],
51
- index.dig(words[primary], nil, nil),
52
- index_entries_opt)
53
- words2 = index[words[primary]]&.keys&.compact
54
- &.each_with_object({}) { |w, v| v[w.downcase] = w }
55
- unless words2.empty?
56
- ret += "<ul>"
57
- words2.keys.localize(@lang.to_sym).sort.to_a.each do |w|
58
- ret += index_entries2(words2, index[words[primary]], w)
59
- end
60
- ret += "</ul>"
61
- end
62
- "#{ret}</li>"
63
- end
64
-
65
- def index_entries2(words, index, secondary)
66
- ret = index_entries_head(words[secondary],
67
- index.dig(words[secondary], nil),
68
- index_entries_opt)
69
- words3 = index[words[secondary]]&.keys&.compact
70
- &.each_with_object({}) { |w, v| v[w.downcase] = w }
71
- unless words3.empty?
72
- ret += "<ul>"
73
- words3.keys.localize(@lang.to_sym).sort.to_a.each do |w|
74
- ret += (index_entries_head(words3[w],
75
- index[words[secondary]][words3[w]],
76
- index_entries_opt) + "</li>")
77
- end
78
- ret += "</ul>"
79
- end
80
- "#{ret}</li>"
81
- end
82
-
83
- def index_entries_head(head, entries, opt)
84
- ret = "<li>#{head}"
85
- xref = entries&.dig(:xref)&.join(", ")
86
- see = index_entries_see(entries, :see)
87
- also = index_entries_see(entries, :also)
88
- ret += "#{opt[:xref_lbl]} #{xref}" if xref
89
- ret += "#{opt[:see_lbl]} #{see}" if see
90
- ret += "#{opt[:also_lbl]} #{also}" if also
91
- ret
92
- end
93
-
94
- def index_entries_see(entries, label)
95
- see_sort = entries&.dig(label) or return nil
96
-
97
- x = see_sort.each_with_object({}) do |w, v|
98
- v[sortable(w).downcase] = w
99
- end
100
- x.keys.localize(@lang.to_sym).sort.to_a.map do |k|
101
- # see_sort[k]
102
- x[k]
103
- end.join(", ")
104
- end
105
-
106
- def see_lbl
107
- @lang == "en" ? @i18n.see : "<em>#{@i18n.see}</em>"
108
- end
109
-
110
- def also_lbl
111
- @lang == "en" ? @i18n.see_also : "<em>#{@i18n.see_also}</em>"
112
- end
113
-
114
- def sort_indexterms(terms, see, also)
115
- index = extract_indexterms(terms)
116
- index = extract_indexsee(index, see, :see)
117
- index = extract_indexsee(index, also, :also)
118
- index.keys.sort.each_with_object({}) do |k, v|
119
- v[sortable(k)[0].upcase.transliterate] ||= {}
120
- v[sortable(k)[0].upcase.transliterate][k] = index[k]
121
- end
122
- end
123
-
124
- def extract_indexsee(val, terms, label)
125
- terms.each_with_object(val) do |t, v|
126
- term, term2, term3 = extract_indexterms_init(t)
127
- term_hash_init(v, term, term2, term3, label)
128
- v[term][term2][term3][label] << to_xml(t.at(ns("./target"))&.children)
129
- t.remove
130
- end
131
- end
132
-
133
- def xml_encode_attr(str)
134
- HTMLEntities.new.encode(str, :basic, :hexadecimal)
135
- .gsub(/&#x([^;]+);/) do |_x|
136
- "&#x#{$1.upcase};"
137
- end
138
- end
139
-
140
- # attributes are decoded into UTF-8,
141
- # elements in extract_indexsee are still in entities
142
- def extract_indexterms(terms)
143
- terms.each_with_object({}) do |t, v|
144
- term, term2, term3 = extract_indexterms_init(t)
145
- index2bookmark(t)
146
- term_hash_init(v, term, term2, term3, :xref)
147
- to = t["to"] ? "to='#{t['to']}' " : ""
148
- v[term][term2][term3][:xref] << "<xref target='#{t['id']}' " \
149
- "#{to}pagenumber='true'/>"
150
- end
151
- end
152
-
153
- def extract_indexterms_init(term)
154
- %w(primary secondary tertiary).each_with_object([]) do |x, m|
155
- m << to_xml(term.at(ns("./#{x}"))&.children)
156
- end
157
- end
158
-
159
- def term_hash_init(hash, term, term2, term3, label)
160
- hash[term] ||= {}
161
- hash[term][term2] ||= {}
162
- hash[term][term2][term3] ||= {}
163
- hash[term][term2][term3][label] ||= []
164
- end
165
-
166
- def index2bookmark(node)
167
- node.name = "bookmark"
168
- node.children.each(&:remove)
169
- node["id"] = "_#{UUIDTools::UUID.random_create}"
170
- end
171
- end
172
- end
173
- end