metanorma-iso 2.7.1 → 2.7.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -28,6 +28,9 @@ module IsoDoc
28
28
  revdate = isoxml.at(ns("//bibdata/version/revision-date"))
29
29
  set(:revdate, revdate&.text)
30
30
  docstatus and docstatus1(isoxml, docstatus)
31
+ docscheme = isoxml.at(ns("//presentation-metadata[name" \
32
+ "[text() = 'document-scheme']]/value"))
33
+ docscheme and set(:document_scheme, docscheme.text)
31
34
  end
32
35
 
33
36
  def docstatus1(isoxml, docstatus)
@@ -69,9 +72,8 @@ module IsoDoc
69
72
  ru: "ТЕХНИЧЕСКОЕ ИСПРАВЛЕНИЕ" }.freeze
70
73
 
71
74
  def part_title(part, titlenums, lang)
72
- return "" unless part
73
-
74
- suffix = @c.encode(part.text, :hexadecimal)
75
+ part or return ""
76
+ suffix = part.children.to_xml
75
77
  p = titlenums[:part]
76
78
  titlenums[:part] && titlenums[:subpart] and
77
79
  p = "#{titlenums[:part]}–#{titlenums[:subpart]}"
@@ -98,10 +100,9 @@ module IsoDoc
98
100
  def compose_title(tparts, tnums, lang)
99
101
  main = ""
100
102
  tparts[:main].nil? or
101
- main = @c.encode(tparts[:main].text, :hexadecimal)
103
+ main = tparts[:main].children.to_xml
102
104
  tparts[:intro] and
103
- main = "#{@c.encode(tparts[:intro].text,
104
- :hexadecimal)} — #{main}"
105
+ main = "#{tparts[:intro].children.to_xml} — #{main}"
105
106
  if tparts[:part]
106
107
  suffix = part_title(tparts[:part], tnums, lang)
107
108
  main = "#{main} — #{suffix}"
@@ -136,18 +137,14 @@ module IsoDoc
136
137
  # intro, main, part, amd = title_parts(isoxml, lang)
137
138
  tp = title_parts(isoxml, lang)
138
139
  tn = title_nums(isoxml)
139
-
140
- set(:doctitlemain,
141
- @c.encode(tp[:main] ? tp[:main].text : "", :hexadecimal))
140
+ set(:doctitlemain, tp[:main] ? tp[:main].children.to_xml : "")
142
141
  main = compose_title(tp, tn, lang)
143
142
  set(:doctitle, main)
144
- tp[:intro] and
145
- set(:doctitleintro,
146
- @c.encode(tp[:intro] ? tp[:intro].text : "", :hexadecimal))
143
+ tp[:intro] and set(:doctitleintro, tp[:intro].children.to_xml)
147
144
  set(:doctitlepartlabel, part_prefix(tn, lang))
148
- set(:doctitlepart, @c.encode(tp[:part].text, :hexadecimal)) if tp[:part]
145
+ set(:doctitlepart, tp[:part].children.to_xml) if tp[:part]
149
146
  set(:doctitleamdlabel, amd_prefix(tn, lang)) if tn[:amd]
150
- set(:doctitleamd, @c.encode(tp[:amd].text, :hexadecimal)) if tp[:amd]
147
+ set(:doctitleamd, tp[:amd].children.to_xml) if tp[:amd]
151
148
  set(:doctitlecorrlabel, corr_prefix(tn, lang)) if tn[:corr]
152
149
  end
153
150
 
@@ -156,19 +153,14 @@ module IsoDoc
156
153
  tp = title_parts(isoxml, lang)
157
154
  tn = title_nums(isoxml)
158
155
 
159
- set(:docsubtitlemain,
160
- @c.encode(tp[:main] ? tp[:main].text : "", :hexadecimal))
156
+ set(:docsubtitlemain, tp[:main] ? tp[:main].children.to_xml : "")
161
157
  main = compose_title(tp, tn, lang)
162
158
  set(:docsubtitle, main)
163
- tp[:intro] and
164
- set(:docsubtitleintro,
165
- @c.encode(tp[:intro] ? tp[:intro].text : "", :hexadecimal))
159
+ tp[:intro] and set(:docsubtitleintro, tp[:intro].children.to_xml)
166
160
  set(:docsubtitlepartlabel, part_prefix(tn, lang))
167
- tp[:part] and
168
- set(:docsubtitlepart,
169
- @c.encode(tp[:part].text, :hexadecimal))
161
+ tp[:part] and set(:docsubtitlepart, tp[:part].children.to_xml)
170
162
  set(:docsubtitleamdlabel, amd_prefix(tn, lang)) if tn[:amd]
171
- set(:docsubtitleamd, @c.encode(tp[:amd].text, :hexadecimal)) if tp[:amd]
163
+ set(:docsubtitleamd, tp[:amd].children.to_xml) if tp[:amd]
172
164
  set(:docsubtitlecorrlabel, corr_prefix(tn, lang)) if tn[:corr]
173
165
  end
174
166
 
@@ -68,9 +68,24 @@ module IsoDoc
68
68
  edition_translate(bib)
69
69
  end
70
70
 
71
- def bibdata_i18n_stage(bib, stage, type, lang: @lang, i18n: @i18n)
72
- return unless stage
71
+ def edition_translate(bibdata)
72
+ super
73
+ @lang == "fr" and e = bibdata.at(ns("./edition[@language = 'fr']")) and
74
+ e.children = e.text.sub(/(\d+)(\p{L}+)/, "\\1<sup>\\2</sup>")
75
+ @docscheme == "1951" and edition_replacement(bibdata)
76
+ end
73
77
 
78
+ def edition_replacement(bibdata)
79
+ e = bibdata.at(ns("./edition[not(@language) or @language = '']"))&.text
80
+ if /^\d+$/.match?(e) && e.to_i > 1
81
+ h = { "var1" => e.to_i, "var2" => e.to_i - 1 }
82
+ x = @i18n.populate("edition_replacement", h)
83
+ bibdata.at(ns("./ext")) << "<edn-replacement>#{x}</edn-replacement>"
84
+ end
85
+ end
86
+
87
+ def bibdata_i18n_stage(bib, stage, type, lang: @lang, i18n: @i18n)
88
+ stage or return
74
89
  i18n.get.dig("stage_dict", stage.text).is_a?(Hash) or
75
90
  return hash_translate(bib, i18n.get["stage_dict"],
76
91
  "./status/stage", lang)
@@ -9,6 +9,11 @@ require_relative "../../relaton/render/general"
9
9
  module IsoDoc
10
10
  module Iso
11
11
  class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
12
+ def convert_i18n_init(docxml)
13
+ super
14
+ update_i18n(docxml)
15
+ end
16
+
12
17
  def convert1(docxml, filename, dir)
13
18
  @iso_class = instance_of?(IsoDoc::Iso::PresentationXMLConvert)
14
19
  if amd?(docxml)
@@ -49,8 +54,8 @@ module IsoDoc
49
54
  def figure1(node)
50
55
  lbl = @xrefs.anchor(node["id"], :label, false) or return
51
56
  figname = node.parent.name == "figure" ? "" : "#{@i18n.figure} "
52
- connective = node.parent.name == "figure" ? "&#xa0; " : "&#xa0;&#x2014; "
53
- prefix_name(node, connective, l10n("#{figname}#{lbl}"), "name")
57
+ conn = node.parent.name == "figure" ? "&#xa0; " : "&#xa0;&#x2014; "
58
+ prefix_name(node, conn, l10n("#{figname}#{lbl}"), "name")
54
59
  end
55
60
 
56
61
  def example1(node)
@@ -62,8 +67,7 @@ module IsoDoc
62
67
  end
63
68
 
64
69
  def example_span_label(_node, div, name)
65
- return if name.nil?
66
-
70
+ name.nil? and return
67
71
  div.span class: "example_label" do |_p|
68
72
  name.children.each { |n| parse(n, div) }
69
73
  end
@@ -172,15 +176,23 @@ module IsoDoc
172
176
 
173
177
  def middle_title_main
174
178
  ret = "<span class='boldtitle'>#{@meta.get[:doctitleintro]}"
175
- ret += " &#x2014; " if @meta.get[:doctitleintro] && @meta.get[:doctitlemain]
179
+ @meta.get[:doctitleintro] && @meta.get[:doctitlemain] and
180
+ ret += " &#x2014; "
176
181
  ret += @meta.get[:doctitlemain]
177
- ret += " &#x2014; " if @meta.get[:doctitlemain] && @meta.get[:doctitlepart]
178
- ret += "</span>"
182
+ @meta.get[:doctitlemain] && @meta.get[:doctitlepart] and
183
+ ret += " &#x2014; "
184
+ ret += "</span>#{middle_title_part}"
185
+ "<p class='zzSTDTitle1'>#{ret}</p>"
186
+ end
187
+
188
+ def middle_title_part
189
+ ret = ""
179
190
  if a = @meta.get[:doctitlepart]
180
- b = @meta.get[:doctitlepartlabel] and ret += "<span class='nonboldtitle'>#{b}:</span> "
191
+ b = @meta.get[:doctitlepartlabel] and
192
+ ret += "<span class='nonboldtitle'>#{b}:</span> "
181
193
  ret += "<span class='boldtitle'>#{a}</span>"
182
194
  end
183
- "<p class='zzSTDTitle1'>#{ret}</p>"
195
+ ret
184
196
  end
185
197
 
186
198
  def middle_title_amd
@@ -1,4 +1,24 @@
1
1
  == copyright-statement
2
+ {% if document_scheme == "1951" %}
3
+
4
+ === REPRODUCTION INTERDITE
5
+
6
+ [[boilerplate-message]]
7
+ Le droit de reproduction des Recommandations ISO et des Normes
8
+ ISO est la propriété des Comités Membres de l’ISO. En
9
+ conséquence, dans chaque pays, la reproduction de ces documents ne
10
+ peut être autorisée que par l’organisation nationale de
11
+ normalisation sation de ce pays, membre de I’ISO.
12
+
13
+ Seules les normes nationales sont valables dans leurs pays respectifs.
14
+
15
+ [[boilerplate-place]]
16
+ Imprimé en Suisse
17
+
18
+ Ce document est également édité en anglais et en russe. Il peut être obtenu auprès des organisations +
19
+ nationales de normalisation.
20
+
21
+ {% else %}
2
22
  === {% if stage_int >= 40 %}DOCUMENT PROTÉGÉ PAR COPYRIGHT{%else%}{blank}{%endif%}
3
23
 
4
24
  [[boilerplate-year]]
@@ -32,3 +52,4 @@ Ce document n'est pas une Norme internationale de l'ISO. Il est distribué pour
32
52
 
33
53
  Les destinataires du présent projet sont invités à présenter, avec leurs observations, notification des droits de propriété dont ils auraient éventuellement connaissance et à fournir une documentation explicative.
34
54
  {% endif %}
55
+ {% endif %}
@@ -1,5 +1,25 @@
1
1
  == copyright-statement
2
2
 
3
+ {% if document_scheme == "1951" %}
4
+
5
+ === COPYRIGHT RESERVED
6
+
7
+ [[boilerplate-message]]
8
+ The copyright of ISO Recommendations and ISO Standards
9
+ belongs to ISO Member Bodies. Reproduction of these
10
+ documents, in any country, may be authorized therefore only
11
+ by the national standards organization of that country, being
12
+ a member of ISO.
13
+
14
+ For each individual country the only valid standard is the national standard of that country.
15
+
16
+ [[boilerplate-place]]
17
+ Printed in Switzerland
18
+
19
+ Also issued in French and Russian. Copies to be obtained through the national standards organizations.
20
+
21
+ {% else %}
22
+
3
23
  === {% if stage_int >= 40 %}COPYRIGHT PROTECTED DOCUMENT{% else %}{blank}{% endif %}
4
24
 
5
25
  [[boilerplate-year]]
@@ -38,3 +58,4 @@ of this draft are invited to submit, with their comments, notification of any
38
58
  relevant patent rights of which they are aware and to provide supporting
39
59
  documentation.
40
60
  {% endif %}
61
+ {% endif %}
@@ -1,9 +1,5 @@
1
1
  require "date"
2
- require "nokogiri"
3
- require "htmlentities"
4
- require "json"
5
2
  require "pathname"
6
- require "open-uri"
7
3
  require "twitter_cldr"
8
4
  require "pubid-iso"
9
5
  require "pubid-cen"
@@ -20,21 +16,20 @@ module Metanorma
20
16
  node.attr("tc-docnumber")&.split(/,\s*/)&.each do |n|
21
17
  xml.docidentifier(n, **attr_code(type: "iso-tc"))
22
18
  end
23
- xml.docnumber node.attr("docnumber")
24
19
  end
25
20
 
21
+ DOCTYPE2HASHID =
22
+ { directive: :dir, "technical-report": :tr, "guide": :guide,
23
+ "technical-specification": :ts,
24
+ "publicly-available-specification": :pas,
25
+ "committee-document": :tc }.freeze
26
+
26
27
  # @param type [nil, :tr, :ts, :amd, :cor, :guide, :dir, :tc, Type]
27
28
  # document's type, eg. :tr, :ts, :amd, :cor, Type.new(:tr)
28
29
  def get_typeabbr(node, amd: false)
29
30
  node.attr("amendment-number") and return :amd
30
31
  node.attr("corrigendum-number") and return :cor
31
- case doctype(node)
32
- when "directive" then :dir
33
- when "technical-report" then :tr
34
- when "technical-specification" then :ts
35
- when "publicly-available-specification" then :pas
36
- when "guide" then :guide
37
- end
32
+ DOCTYPE2HASHID[doctype(node).to_sym]
38
33
  end
39
34
 
40
35
  def iso_id(node, xml)
@@ -80,6 +75,10 @@ module Metanorma
80
75
  end
81
76
  end
82
77
 
78
+ def compact_blank(hash)
79
+ hash.compact.reject { |_, v| v.is_a?(String) && v.empty? }
80
+ end
81
+
83
82
  # unpublished is for internal use
84
83
  def iso_id_params_core(node)
85
84
  pub = iso_id_pub(node)
@@ -89,9 +88,9 @@ module Metanorma
89
88
  type: get_typeabbr(node),
90
89
  publisher: pub[0],
91
90
  unpublished: /^[0-5]/.match?(get_stage(node)),
92
- copublisher: pub[1..-1] }.compact
91
+ copublisher: pub[1..-1] }
93
92
  ret[:copublisher].empty? and ret.delete(:copublisher)
94
- ret
93
+ compact_blank(ret)
95
94
  end
96
95
 
97
96
  def iso_id_pub(node)
@@ -104,7 +103,24 @@ module Metanorma
104
103
  ret = { number: node.attr("amendment-number") ||
105
104
  node.attr("corrigendum-number"),
106
105
  year: iso_id_year(node),
107
- iteration: node.attr("iteration") }.compact
106
+ iteration: node.attr("iteration") }
107
+ iso_id_stage_populate(ret, node, stage)
108
+ tc_number(ret, node)
109
+ compact_blank(ret)
110
+ end
111
+
112
+ def tc_number(ret, node)
113
+ doctype(node) == "committee-document" or return ret
114
+ n = node.attr("subcommittee-number") and
115
+ ret.merge!({ sctype: node.attr("subcommittee-type") || "SC",
116
+ scnumber: n })
117
+ n = node.attr("technical-committee-number") and
118
+ ret.merge!({ tctype: node.attr("technical-committee-type") || "TC",
119
+ tcnumber: n })
120
+ ret
121
+ end
122
+
123
+ def iso_id_stage_populate(ret, node, stage)
108
124
  if stage && !cen?(node.attr("publisher"))
109
125
  ret[:stage] = stage
110
126
  ret[:stage] == "60.00" and ret[:stage] = :PRF
@@ -101,6 +101,7 @@
101
101
  <value>amendment</value>
102
102
  <value>technical-corrigendum</value>
103
103
  <value>directive</value>
104
+ <value>committee-document</value>
104
105
  </choice>
105
106
  </define>
106
107
  <define name="DocumentSubtype">
@@ -119,7 +119,8 @@ module Metanorma
119
119
  def doctype_validate(_xmldoc)
120
120
  %w(international-standard technical-specification technical-report
121
121
  publicly-available-specification international-workshop-agreement
122
- guide amendment technical-corrigendum).include? @doctype or
122
+ guide amendment technical-corrigendum committee-document)
123
+ .include? @doctype or
123
124
  @log.add("Document Attributes", nil,
124
125
  "#{@doctype} is not a recognised document type")
125
126
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ISO
3
- VERSION = "2.7.1".freeze
3
+ VERSION = "2.7.2".freeze
4
4
  end
5
5
  end
@@ -32,14 +32,12 @@ Gem::Specification.new do |spec|
32
32
  spec.test_files = `git ls-files -- {spec}/*`.split("\n")
33
33
  spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
34
34
 
35
- spec.add_dependency "metanorma-standoc", "~> 2.8.0"
35
+ spec.add_dependency "metanorma-standoc", "~> 2.8.2"
36
36
  spec.add_dependency "mnconvert", "~> 1.14"
37
- spec.add_dependency "pubid-iso"
38
37
  spec.add_dependency "pubid-cen"
39
38
  spec.add_dependency "pubid-iec"
40
- spec.add_dependency "ruby-jing"
39
+ spec.add_dependency "pubid-iso"
41
40
  spec.add_dependency "tokenizer", "~> 0.3.0"
42
- spec.add_dependency "twitter_cldr"
43
41
 
44
42
  spec.add_development_dependency "debug"
45
43
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
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.7.1
4
+ version: 2.7.2
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-02-05 00:00:00.000000000 Z
11
+ date: 2024-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-standoc
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.8.0
19
+ version: 2.8.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.8.0
26
+ version: 2.8.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mnconvert
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.14'
41
- - !ruby/object:Gem::Dependency
42
- name: pubid-iso
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: pubid-cen
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -81,7 +67,7 @@ dependencies:
81
67
  - !ruby/object:Gem::Version
82
68
  version: '0'
83
69
  - !ruby/object:Gem::Dependency
84
- name: ruby-jing
70
+ name: pubid-iso
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
73
  - - ">="
@@ -108,20 +94,6 @@ dependencies:
108
94
  - - "~>"
109
95
  - !ruby/object:Gem::Version
110
96
  version: 0.3.0
111
- - !ruby/object:Gem::Dependency
112
- name: twitter_cldr
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :runtime
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
97
  - !ruby/object:Gem::Dependency
126
98
  name: debug
127
99
  requirement: !ruby/object:Gem::Requirement