metanorma-iec 1.4.5 → 2.0.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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +4 -32
  3. data/.gitignore +14 -0
  4. data/Gemfile +4 -0
  5. data/lib/isodoc/iec/base_convert.rb +3 -2
  6. data/lib/isodoc/iec/html/htmlstyle.css +23 -17
  7. data/lib/isodoc/iec/html/htmlstyle.scss +9 -3
  8. data/lib/isodoc/iec/html/isodoc.css +1 -2
  9. data/lib/isodoc/iec/html/isodoc.scss +0 -1
  10. data/lib/isodoc/iec/html_convert.rb +2 -1
  11. data/lib/isodoc/iec/i18n-fr.yaml +1 -1
  12. data/lib/isodoc/iec/iec.international-standard.xsl +2198 -1850
  13. data/lib/isodoc/iec/word_convert.rb +2 -0
  14. data/lib/isodoc/iec/xref.rb +9 -8
  15. data/lib/{asciidoctor → metanorma}/iec/basicdoc.rng +5 -3
  16. data/lib/{asciidoctor → metanorma}/iec/biblio.rng +7 -5
  17. data/lib/{asciidoctor → metanorma}/iec/converter.rb +22 -8
  18. data/lib/{asciidoctor → metanorma}/iec/front.rb +1 -1
  19. data/lib/{asciidoctor → metanorma}/iec/iec.rng +0 -0
  20. data/lib/{asciidoctor → metanorma}/iec/iec_intro_en.xml +0 -0
  21. data/lib/{asciidoctor → metanorma}/iec/iec_intro_fr.xml +0 -0
  22. data/lib/{asciidoctor → metanorma}/iec/isodoc.rng +98 -1
  23. data/lib/{asciidoctor → metanorma}/iec/isostandard.rng +0 -0
  24. data/lib/{asciidoctor → metanorma}/iec/reqt.rng +0 -0
  25. data/lib/metanorma/iec/version.rb +1 -1
  26. data/lib/metanorma-iec.rb +1 -1
  27. data/metanorma-iec.gemspec +1 -1
  28. data/spec/isodoc/i18n_spec.rb +2 -2
  29. data/spec/isodoc/iev_spec.rb +6 -5
  30. data/spec/isodoc/ref_spec.rb +359 -353
  31. data/spec/{asciidoctor → metanorma}/base_spec.rb +1 -1
  32. data/spec/{asciidoctor → metanorma}/blocks_spec.rb +1 -1
  33. data/spec/{asciidoctor → metanorma}/cleanup_spec.rb +1 -1
  34. data/spec/{asciidoctor → metanorma}/iev_spec.rb +10 -2
  35. data/spec/{asciidoctor → metanorma}/inline_spec.rb +1 -1
  36. data/spec/{asciidoctor → metanorma}/lists_spec.rb +1 -1
  37. data/spec/{asciidoctor → metanorma}/section_spec.rb +1 -1
  38. data/spec/{asciidoctor → metanorma}/validate_spec.rb +1 -1
  39. data/spec/spec_helper.rb +2 -2
  40. metadata +22 -22
@@ -221,10 +221,12 @@ module IsoDoc
221
221
  end
222
222
 
223
223
  def annex_name(_annex, name, div)
224
+ preceding_floating_titles(name, div)
224
225
  return if name.nil?
225
226
 
226
227
  div.h1 **{ class: "Annex" } do |t|
227
228
  name.children.each { |c2| parse(c2, t) }
229
+ clause_parse_subtitle(name, t)
228
230
  end
229
231
  end
230
232
 
@@ -16,6 +16,7 @@ module IsoDoc
16
16
  def initial_anchor_names(d)
17
17
  super
18
18
  return unless @is_iev
19
+
19
20
  terms_iev_names(d)
20
21
  middle_section_asset_names(d)
21
22
  termnote_anchor_names(d)
@@ -24,21 +25,21 @@ module IsoDoc
24
25
 
25
26
  def terms_iev_names(d)
26
27
  d.xpath(ns("//sections/clause/terms")).each_with_index do |t, i|
27
- num = "#{@iev_part}-%02d" % [i+1]
28
+ num = "#{@iev_part}-%02d" % [i + 1]
28
29
  @anchors[t["id"]] =
29
- { label: num, xref: l10n("#{@labels["section_iev"]}-#{num}"), level: 2,
30
- type: "clause" }
31
- t.xpath(ns("./term")).each_with_index do |c, i|
32
- num2 = "%02d" % [i+1]
30
+ { label: num, xref: l10n("#{@labels['section_iev']} #{num}"),
31
+ level: 2, type: "clause" }
32
+ t.xpath(ns("./term")).each_with_index do |c, j|
33
+ num2 = "%02d" % [j + 1]
33
34
  section_names1(c, "#{num}-#{num2}", 3)
34
35
  end
35
36
  end
36
37
  end
37
38
 
38
39
  def annex_name_lbl(clause, num)
39
- obl = l10n("(#{@labels["inform_annex"]})")
40
- obl = l10n("(#{@labels["norm_annex"]})") if clause["obligation"] == "normative"
41
- l10n("<strong>#{@labels["annex"]} #{num}</strong><br/>#{obl}")
40
+ obl = l10n("(#{@labels['inform_annex']})")
41
+ obl = l10n("(#{@labels['norm_annex']})") if clause["obligation"] == "normative"
42
+ l10n("<strong>#{@labels['annex']} #{num}</strong><br/>#{obl}")
42
43
  end
43
44
  end
44
45
  end
@@ -173,9 +173,11 @@
173
173
  <data type="dateTime"/>
174
174
  </attribute>
175
175
  </optional>
176
- <attribute name="from">
177
- <data type="IDREF"/>
178
- </attribute>
176
+ <optional>
177
+ <attribute name="from">
178
+ <data type="IDREF"/>
179
+ </attribute>
180
+ </optional>
179
181
  <optional>
180
182
  <attribute name="to">
181
183
  <data type="IDREF"/>
@@ -209,9 +209,6 @@
209
209
  <zeroOrMore>
210
210
  <ref name="contact"/>
211
211
  </zeroOrMore>
212
- <zeroOrMore>
213
- <ref name="uri"/>
214
- </zeroOrMore>
215
212
  </element>
216
213
  </define>
217
214
  <define name="fullname">
@@ -401,9 +398,9 @@
401
398
  <choice>
402
399
  <!-- iso191606 TODO -->
403
400
  <group>
404
- <oneOrMore>
401
+ <zeroOrMore>
405
402
  <ref name="street"/>
406
- </oneOrMore>
403
+ </zeroOrMore>
407
404
  <ref name="city"/>
408
405
  <optional>
409
406
  <ref name="state"/>
@@ -828,6 +825,11 @@
828
825
  <optional>
829
826
  <attribute name="scope"/>
830
827
  </optional>
828
+ <optional>
829
+ <attribute name="primary">
830
+ <data type="boolean"/>
831
+ </attribute>
832
+ </optional>
831
833
  <text/>
832
834
  </element>
833
835
  </define>
@@ -1,8 +1,9 @@
1
1
  require "asciidoctor"
2
2
  require "metanorma-iso"
3
+ require "metanorma/iso/converter"
3
4
  require_relative "./front"
4
5
 
5
- module Asciidoctor
6
+ module Metanorma
6
7
  module Iec
7
8
  class Converter < ISO::Converter
8
9
  XML_ROOT_TAG = "iec-standard".freeze
@@ -81,13 +82,6 @@ module Asciidoctor
81
82
  end
82
83
  end
83
84
 
84
- def norm_ref_preface(node)
85
- return super unless @is_iev
86
-
87
- node.at("./title").next =
88
- "<p>#{@i18n.norm_empty_pref}</p>"
89
- end
90
-
91
85
  def term_defs_boilerplate(div, source, term, preface, isodoc)
92
86
  return super unless @is_iev
93
87
  end
@@ -117,6 +111,26 @@ module Asciidoctor
117
111
  end
118
112
 
119
113
  def image_name_validate(xmldoc); end
114
+
115
+ def toc_cleanup(xmldoc)
116
+ toc_iev_cleanup(xmldoc) if @is_iev
117
+ super
118
+ end
119
+
120
+ def toc_iev_cleanup(xmldoc)
121
+ iev_variant_titles(xmldoc)
122
+ end
123
+
124
+ def iev_variant_titles(xmldoc)
125
+ id = xmldoc&.at("//bibdata/docidentifier[@type = 'ISO']")&.text
126
+ m = /60050-(\d+)/.match(id) or return
127
+ xmldoc.xpath("//sections/clause/terms/title").each_with_index do |t, i|
128
+ num = "%02d" % [i + 1]
129
+ t.next = "<variant-title type='toc'>"\
130
+ "#{@i18n.section_iev} #{m[1]}-#{num} &#x2013; "\
131
+ "#{t.children.to_xml}</variant-title>"
132
+ end
133
+ end
120
134
  end
121
135
  end
122
136
  end
@@ -1,4 +1,4 @@
1
- module Asciidoctor
1
+ module Metanorma
2
2
  module Iec
3
3
  class Converter < ISO::Converter
4
4
  def metadata_author(node, xml)
File without changes
File without changes
File without changes
@@ -32,6 +32,56 @@
32
32
  <ref name="DocumentType"/>
33
33
  </element>
34
34
  </define>
35
+ <define name="index">
36
+ <element name="index">
37
+ <optional>
38
+ <attribute name="to">
39
+ <data type="IDREF"/>
40
+ </attribute>
41
+ </optional>
42
+ <element name="primary">
43
+ <oneOrMore>
44
+ <choice>
45
+ <ref name="PureTextElement"/>
46
+ <ref name="stem"/>
47
+ </choice>
48
+ </oneOrMore>
49
+ </element>
50
+ <optional>
51
+ <element name="secondary">
52
+ <oneOrMore>
53
+ <choice>
54
+ <ref name="PureTextElement"/>
55
+ <ref name="stem"/>
56
+ </choice>
57
+ </oneOrMore>
58
+ </element>
59
+ </optional>
60
+ <optional>
61
+ <element name="tertiary">
62
+ <oneOrMore>
63
+ <choice>
64
+ <ref name="PureTextElement"/>
65
+ <ref name="stem"/>
66
+ </choice>
67
+ </oneOrMore>
68
+ </element>
69
+ </optional>
70
+ </element>
71
+ </define>
72
+ <define name="bibitem">
73
+ <element name="bibitem">
74
+ <attribute name="id">
75
+ <data type="ID"/>
76
+ </attribute>
77
+ <optional>
78
+ <attribute name="hidden">
79
+ <data type="boolean"/>
80
+ </attribute>
81
+ </optional>
82
+ <ref name="BibliographicItem"/>
83
+ </element>
84
+ </define>
35
85
  <define name="section-title">
36
86
  <element name="title">
37
87
  <zeroOrMore>
@@ -690,6 +740,7 @@
690
740
  <ref name="terms"/>
691
741
  <ref name="term-clause"/>
692
742
  <ref name="definitions"/>
743
+ <ref name="floating-title"/>
693
744
  </choice>
694
745
  </oneOrMore>
695
746
  </element>
@@ -1013,6 +1064,26 @@
1013
1064
  </zeroOrMore>
1014
1065
  </element>
1015
1066
  </define>
1067
+ <define name="sub">
1068
+ <element name="sub">
1069
+ <zeroOrMore>
1070
+ <choice>
1071
+ <ref name="PureTextElement"/>
1072
+ <ref name="stem"/>
1073
+ </choice>
1074
+ </zeroOrMore>
1075
+ </element>
1076
+ </define>
1077
+ <define name="sup">
1078
+ <element name="sup">
1079
+ <zeroOrMore>
1080
+ <choice>
1081
+ <ref name="PureTextElement"/>
1082
+ <ref name="stem"/>
1083
+ </choice>
1084
+ </zeroOrMore>
1085
+ </element>
1086
+ </define>
1016
1087
  <define name="pagebreak">
1017
1088
  <element name="pagebreak">
1018
1089
  <optional>
@@ -1680,6 +1751,7 @@
1680
1751
  <ref name="clause-subsection"/>
1681
1752
  <ref name="terms"/>
1682
1753
  <ref name="definitions"/>
1754
+ <ref name="floating-title"/>
1683
1755
  </choice>
1684
1756
  </oneOrMore>
1685
1757
  </choice>
@@ -1722,6 +1794,7 @@
1722
1794
  <ref name="terms"/>
1723
1795
  <ref name="definitions"/>
1724
1796
  <ref name="references"/>
1797
+ <ref name="floating-title"/>
1725
1798
  </choice>
1726
1799
  </zeroOrMore>
1727
1800
  </group>
@@ -2200,7 +2273,18 @@
2200
2273
  <ref name="MultilingualRenderingType"/>
2201
2274
  </attribute>
2202
2275
  </optional>
2203
- <ref name="paragraph"/>
2276
+ <oneOrMore>
2277
+ <choice>
2278
+ <ref name="formula"/>
2279
+ <ref name="ul"/>
2280
+ <ref name="ol"/>
2281
+ <ref name="dl"/>
2282
+ <ref name="quote"/>
2283
+ <ref name="sourcecode"/>
2284
+ <ref name="paragraph"/>
2285
+ <ref name="figure"/>
2286
+ </choice>
2287
+ </oneOrMore>
2204
2288
  </element>
2205
2289
  </define>
2206
2290
  <define name="termsource">
@@ -2534,4 +2618,17 @@
2534
2618
  </oneOrMore>
2535
2619
  </element>
2536
2620
  </define>
2621
+ <define name="floating-title">
2622
+ <element name="floating-title">
2623
+ <attribute name="id">
2624
+ <data type="ID"/>
2625
+ </attribute>
2626
+ <attribute name="depth">
2627
+ <data type="int"/>
2628
+ </attribute>
2629
+ <zeroOrMore>
2630
+ <ref name="TextElement"/>
2631
+ </zeroOrMore>
2632
+ </element>
2633
+ </define>
2537
2634
  </grammar>
File without changes
File without changes
@@ -1,6 +1,6 @@
1
1
  module Metanorma
2
2
  module Iec
3
- VERSION = "1.4.5".freeze
3
+ VERSION = "2.0.3".freeze
4
4
  end
5
5
  end
6
6
 
data/lib/metanorma-iec.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require "asciidoctor" unless defined? Asciidoctor::Converter
2
- require_relative "asciidoctor/iec/converter"
2
+ require_relative "metanorma/iec/converter"
3
3
  require_relative "metanorma/iec/version"
4
4
  require "isodoc/iec/html_convert"
5
5
  require "isodoc/iec/word_convert"
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.test_files = `git ls-files -- {spec}/*`.split("\n")
28
28
  spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
29
29
 
30
- spec.add_dependency "metanorma-iso", "~> 1.10.0"
30
+ spec.add_dependency "metanorma-iso", "~> 2.0.0"
31
31
  spec.add_dependency "ruby-jing"
32
32
 
33
33
  spec.add_development_dependency "debug"
@@ -83,7 +83,7 @@ RSpec.describe IsoDoc do
83
83
  <docnumber>1</docnumber>
84
84
  <language current="true">en</language>
85
85
  <ext>
86
- <doctype language="">international-standard</doctype><doctype language="fr">Norme international</doctype><doctype language="en">International Standard</doctype>
86
+ <doctype language="">international-standard</doctype><doctype language="fr">Norme internationale</doctype><doctype language="en">International Standard</doctype>
87
87
  <horizontal language="">true</horizontal><horizontal language="fr">Norme horizontale</horizontal><horizontal language="en">Horizontal Standard</horizontal>
88
88
  <function language="">emc</function><function language="fr">Publication fondamentale en CEM</function><function language="en">Basic EMC Publication</function>
89
89
  </ext>
@@ -444,7 +444,7 @@ RSpec.describe IsoDoc do
444
444
  <bibdata>
445
445
  <language current="true">fr</language>
446
446
  <ext>
447
- <doctype language="">international-standard</doctype><doctype language="fr">Norme international</doctype><doctype language="en">International Standard</doctype>
447
+ <doctype language="">international-standard</doctype><doctype language="fr">Norme internationale</doctype><doctype language="en">International Standard</doctype>
448
448
  <horizontal language="">false</horizontal>
449
449
  <function language="">emc</function><function language="fr">Publication fondamentale en CEM</function><function language="en">Basic EMC Publication</function>
450
450
  </ext>
@@ -211,6 +211,7 @@ RSpec.describe IsoDoc do
211
211
  <formattedref format='application/x-isodoc+xml'>
212
212
  <em>TITLE</em>
213
213
  </formattedref>
214
+ <docidentifier type='metanorma-ordinal'>[1]</docidentifier>
214
215
  <docidentifier>B</docidentifier>
215
216
  </bibitem>
216
217
  </references>
@@ -369,9 +370,9 @@ RSpec.describe IsoDoc do
369
370
  <h1>1&#160; Terms and definitions</h1>
370
371
  <br/>
371
372
  <div id='_general'>
372
- <p class='zzSTDTitle2'>
373
+ <h2 class='zzSTDTitle2'>
373
374
  <b>192-01 General</b>
374
- </p>
375
+ </h2>
375
376
  <p class='TermNum' id='paddy1'>192-01-01</p>
376
377
  <p class='Terms' style='text-align:left;'>
377
378
  <b>paddy</b>
@@ -537,9 +538,9 @@ RSpec.describe IsoDoc do
537
538
  </p>
538
539
  <div>
539
540
  <a name='_general' id='_general'/>
540
- <p class='zzSTDTitle2'>
541
+ <h2 class='zzSTDTitle2'>
541
542
  <b>192-01 General</b>
542
- </p>
543
+ </h2>
543
544
  <p class='TermNum'>
544
545
  <a name='paddy1' id='paddy1'/>
545
546
  192-01-01
@@ -600,7 +601,7 @@ RSpec.describe IsoDoc do
600
601
  <docnumber>60050</docnumber>
601
602
  <ext>
602
603
  <doctype language=''>international-standard</doctype>
603
- <doctype language='fr'>Norme international</doctype>
604
+ <doctype language='fr'>Norme internationale</doctype>
604
605
  <doctype language='en'>International Standard</doctype>
605
606
  <horizontal language=''>false</horizontal>
606
607
  <structuredidentifier>