metanorma-iec 2.2.8 → 2.2.10

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.
@@ -28,9 +28,8 @@ module IsoDoc
28
28
  end
29
29
 
30
30
  def termclause1(elem)
31
- return clause1(elem) unless @is_iev
32
- return if @suppressheadingnumbers || elem["unnumbered"]
33
-
31
+ @is_iev or return clause1(elem)
32
+ @suppressheadingnumbers || elem["unnumbered"] and return
34
33
  lbl = @xrefs.anchor(elem["id"], :label, true) or return
35
34
  prefix_name(elem, " ", "#{lbl}#{clausedelim}", "title")
36
35
  end
@@ -88,8 +87,7 @@ module IsoDoc
88
87
  end
89
88
 
90
89
  def merge_fr_into_en_term(docxml)
91
- return unless @is_iev
92
-
90
+ @is_iev or return
93
91
  docxml.xpath(ns("//term[@language = 'en'][@tag]")).each do |en|
94
92
  fr = docxml.at(ns("//term[@language = 'fr'][@tag = '#{en['tag']}']"))
95
93
  merge_fr_into_en_term1(en, fr) if fr
@@ -108,8 +106,7 @@ module IsoDoc
108
106
  end
109
107
 
110
108
  def otherlang_designations(docxml)
111
- return unless @is_iev
112
-
109
+ @is_iev or return
113
110
  docxml.xpath(ns("//term")).each do |t|
114
111
  otherlang_designations1(t, t["language"]&.split(/,/) || %w(en fr))
115
112
  end
@@ -133,8 +130,7 @@ module IsoDoc
133
130
  script = Metanorma::Utils.default_script(lang)
134
131
  c = HTMLEntities.new
135
132
  xml.traverse do |x|
136
- next unless x.text?
137
-
133
+ x.text? or next
138
134
  text = c.encode(c.decode(x.text), :hexadecimal)
139
135
  x.replace(cleanup_entities(l10n(text, lang, script), is_xml: false))
140
136
  end
@@ -155,8 +151,7 @@ module IsoDoc
155
151
  pr = merge_otherlang_designations(
156
152
  extract_otherlang_designations(term, lgs),
157
153
  )
158
- return if pr.empty?
159
-
154
+ pr.empty? and return
160
155
  prefs = pr.map do |p|
161
156
  "<dt>#{p[:lang]}</dt>" \
162
157
  "<dd language='#{p[:lang]}' script='#{p[:script]}'>" \
@@ -239,6 +234,59 @@ module IsoDoc
239
234
  i18nhash: @i18n.get)
240
235
  end
241
236
 
237
+ def rearrange_clauses(docxml)
238
+ insert_foreword(docxml) # feeds preface_rearrange
239
+ super
240
+ insert_middle_title(docxml)
241
+ end
242
+
243
+ def insert_foreword(docxml)
244
+ @meta.get[:doctype] == "Amendment" and return
245
+ b = docxml.at(ns("//boilerplate/legal-statement")) or return
246
+ unless f = docxml.at(ns("//preface/foreword"))
247
+ ins = toc_title_insert_pt(docxml)
248
+ f = ins.before(<<~CLAUSE).previous_element
249
+ <foreword id='_#{UUIDTools::UUID.random_create}'> </foreword>
250
+ CLAUSE
251
+ end
252
+ f.children.empty? and f.children = " "
253
+ ins = f.at(ns("./title")) || f.children.first.before(" ").previous
254
+ ins.next =
255
+ "<clause type='boilerplate_legal'>#{to_xml(b.children)}</clause>"
256
+ end
257
+
258
+ def insert_middle_title(docxml)
259
+ ins = docxml.at(ns("//preface/clause[@type = 'toc']")) or return
260
+ title1, title2 = middle_title_parts(nil)
261
+ title2out = ""
262
+ title2 and title2out = <<~OUTPUT
263
+ <p class="zzSTDTitle1">&#xa0;</p>
264
+ <p class="zzSTDTitle2"><strong>#{title2}</strong></p>
265
+ OUTPUT
266
+ ins.next = <<~OUTPUT
267
+ <pagebreak/>
268
+ <p class="zzSTDTitle1">#{@i18n.get['IEC']}</p>
269
+ <p class="zzSTDTitle1">____________</p>
270
+ <p class="zzSTDTitle1">&#xa0;</p>
271
+ <p class="zzSTDTitle1"><strong>#{title1.upcase}</strong></p>#{title2out}
272
+ <p class="zzSTDTitle1">&#xa0;</p>
273
+ OUTPUT
274
+ end
275
+
276
+ def middle_title_parts(_out)
277
+ title1 = @meta.get[:doctitlemain]&.sub(/\s+$/, "")
278
+ @meta.get[:doctitleintro] and
279
+ title1 = "#{@meta.get[:doctitleintro]} \u2014 #{title1}"
280
+ title2 = nil
281
+ if @meta.get[:doctitlepart]
282
+ title1 += " \u2014"
283
+ title2 = @meta.get[:doctitlepart]&.sub(/\s+$/, "")
284
+ @meta.get[:doctitlepartlabel] and
285
+ title2 = "#{@meta.get[:doctitlepartlabel]}: #{title2}"
286
+ end
287
+ [title1, title2]
288
+ end
289
+
242
290
  include Init
243
291
  end
244
292
  end
@@ -13,16 +13,16 @@ module IsoDoc
13
13
 
14
14
  def convert(input_filename, file = nil, debug = false,
15
15
  output_filename = nil)
16
- file = File.read(input_filename, encoding: "utf-8") if file.nil?
17
- @openmathdelim, @closemathdelim = extract_delims(file)
18
- docxml, filename, dir = convert_init(file, input_filename, debug)
19
- result = convert1(docxml, filename, dir)
20
- return result if debug
21
-
22
- output_filename ||= "#{filename}.#{@suffix}"
23
- postprocess(result, output_filename, dir)
24
- FileUtils.rm_rf dir
25
- end
16
+ file = File.read(input_filename, encoding: "utf-8") if file.nil?
17
+ @openmathdelim, @closemathdelim = extract_delims(file)
18
+ docxml, filename, dir = convert_init(file, input_filename, debug)
19
+ result = convert1(docxml, filename, dir)
20
+ return result if debug
21
+
22
+ output_filename ||= "#{filename}.#{@suffix}"
23
+ postprocess(result, output_filename, dir)
24
+ FileUtils.rm_rf dir
25
+ end
26
26
 
27
27
  def font_choice(options)
28
28
  if options[:script] == "Hans" then '"Source Han Sans",serif'
@@ -169,8 +169,8 @@ module IsoDoc
169
169
  docxml.xpath("//div[@class = 'boilerplate_legal']//li").each do |l|
170
170
  l.replace(l.children)
171
171
  end
172
- b = docxml.at("div[@class = 'boilerplate_legal']")
173
- b.replace(b.children)
172
+ b = docxml.at("//div[@class = 'boilerplate_legal']")
173
+ b and b.replace(b.children)
174
174
  end
175
175
 
176
176
  def authority_cleanup(docxml)
@@ -202,11 +202,15 @@ module IsoDoc
202
202
  { class: "TableTitle", style: "text-align:center;" }
203
203
  end
204
204
 
205
- def para_class(_node)
206
- classtype = nil
207
- classtype = "MsoCommentText" if @in_comment
208
- classtype = "Sourcecode" if @annotation
209
- classtype
205
+ def para_class(node)
206
+ case node["class"]
207
+ when "zzSTDTitle1", "zzSTDTitle2" then node["class"]
208
+ else
209
+ classtype = nil
210
+ classtype = "MsoCommentText" if @in_comment
211
+ classtype = "Sourcecode" if @annotation
212
+ classtype
213
+ end
210
214
  end
211
215
 
212
216
  def annex_name(_annex, name, div)
@@ -1,6 +1,9 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <grammar ns="https://www.metanorma.org/ns/iec" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
- <!-- default namespace = "https://www.metanorma.com/ns/iec" -->
2
+ <grammar ns='https://www.metanorma.org/ns/iec' xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
+ <!--
4
+ VERSION v1.2.1
5
+ default namespace = "https://www.metanorma.com/ns/iec"
6
+ -->
4
7
  <include href="relaton-iec.rng"/>
5
8
  <include href="isostandard.rng">
6
9
  <start>
@@ -55,13 +58,7 @@
55
58
  -->
56
59
  <define name="iec-standard">
57
60
  <element name="iec-standard">
58
- <attribute name="version"/>
59
- <attribute name="type">
60
- <choice>
61
- <value>semantic</value>
62
- <value>presentation</value>
63
- </choice>
64
- </attribute>
61
+ <ref name="Root-Attributes"/>
65
62
  <ref name="bibdata"/>
66
63
  <zeroOrMore>
67
64
  <ref name="termdocsource"/>
@@ -17,6 +17,7 @@
17
17
  these elements; we just want one namespace for any child grammars
18
18
  of this.
19
19
  -->
20
+ <!-- VERSION v1.2.2 -->
20
21
  <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">
21
22
  <include href="reqt.rng"/>
22
23
  <include href="basicdoc.rng">
@@ -210,6 +211,9 @@
210
211
  <data type="boolean"/>
211
212
  </attribute>
212
213
  </optional>
214
+ <optional>
215
+ <attribute name="style"/>
216
+ </optional>
213
217
  <ref name="CitationType"/>
214
218
  <oneOrMore>
215
219
  <ref name="PureTextElement"/>
@@ -1349,15 +1353,19 @@
1349
1353
  </choice>
1350
1354
  </element>
1351
1355
  </define>
1356
+ <define name="Root-Attributes">
1357
+ <attribute name="version"/>
1358
+ <attribute name="schema-version"/>
1359
+ <attribute name="type">
1360
+ <choice>
1361
+ <value>semantic</value>
1362
+ <value>presentation</value>
1363
+ </choice>
1364
+ </attribute>
1365
+ </define>
1352
1366
  <define name="standard-document">
1353
1367
  <element name="standard-document">
1354
- <attribute name="version"/>
1355
- <attribute name="type">
1356
- <choice>
1357
- <value>semantic</value>
1358
- <value>presentation</value>
1359
- </choice>
1360
- </attribute>
1368
+ <ref name="Root-Attributes"/>
1361
1369
  <ref name="bibdata"/>
1362
1370
  <optional>
1363
1371
  <ref name="misccontainer"/>
@@ -2131,6 +2139,7 @@
2131
2139
  <choice>
2132
2140
  <value>identical</value>
2133
2141
  <value>modified</value>
2142
+ <value>adapted</value>
2134
2143
  <value>restyled</value>
2135
2144
  <value>context-added</value>
2136
2145
  <value>generalisation</value>
@@ -1,6 +1,9 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
- <!-- default namespace isostandard = "https://www.metanorma.com/ns/iso" -->
3
+ <!--
4
+ VERSION v1.2.1
5
+ default namespace isostandard = "https://www.metanorma.com/ns/iso"
6
+ -->
4
7
  <include href="isodoc.rng">
5
8
  <start>
6
9
  <ref name="iso-standard"/>
@@ -240,13 +243,7 @@
240
243
  -->
241
244
  <define name="iso-standard">
242
245
  <element name="iso-standard">
243
- <attribute name="version"/>
244
- <attribute name="type">
245
- <choice>
246
- <value>semantic</value>
247
- <value>presentation</value>
248
- </choice>
249
- </attribute>
246
+ <ref name="Root-Attributes"/>
250
247
  <ref name="bibdata"/>
251
248
  <zeroOrMore>
252
249
  <ref name="termdocsource"/>
@@ -1,6 +1,6 @@
1
1
  module Metanorma
2
2
  module Iec
3
- VERSION = "2.2.8".freeze
3
+ VERSION = "2.2.10".freeze
4
4
  end
5
5
  end
6
6
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-iec
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.8
4
+ version: 2.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-10 00:00:00.000000000 Z
11
+ date: 2023-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-iso