metanorma-iec 1.4.5 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) 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 +1 -1
  7. data/lib/isodoc/iec/html/htmlstyle.scss +1 -1
  8. data/lib/isodoc/iec/html_convert.rb +2 -1
  9. data/lib/isodoc/iec/iec.international-standard.xsl +294 -214
  10. data/lib/isodoc/iec/xref.rb +9 -8
  11. data/lib/{asciidoctor → metanorma}/iec/basicdoc.rng +0 -0
  12. data/lib/{asciidoctor → metanorma}/iec/biblio.rng +0 -0
  13. data/lib/{asciidoctor → metanorma}/iec/converter.rb +22 -1
  14. data/lib/{asciidoctor → metanorma}/iec/front.rb +1 -1
  15. data/lib/{asciidoctor → metanorma}/iec/iec.rng +0 -0
  16. data/lib/{asciidoctor → metanorma}/iec/iec_intro_en.xml +0 -0
  17. data/lib/{asciidoctor → metanorma}/iec/iec_intro_fr.xml +0 -0
  18. data/lib/{asciidoctor → metanorma}/iec/isodoc.rng +29 -0
  19. data/lib/{asciidoctor → metanorma}/iec/isostandard.rng +0 -0
  20. data/lib/{asciidoctor → metanorma}/iec/reqt.rng +0 -0
  21. data/lib/metanorma/iec/version.rb +1 -1
  22. data/lib/metanorma-iec.rb +1 -1
  23. data/metanorma-iec.gemspec +1 -1
  24. data/spec/isodoc/iev_spec.rb +5 -4
  25. data/spec/isodoc/ref_spec.rb +359 -353
  26. data/spec/{asciidoctor → metanorma}/base_spec.rb +1 -1
  27. data/spec/{asciidoctor → metanorma}/blocks_spec.rb +1 -1
  28. data/spec/{asciidoctor → metanorma}/cleanup_spec.rb +1 -1
  29. data/spec/{asciidoctor → metanorma}/iev_spec.rb +1 -1
  30. data/spec/{asciidoctor → metanorma}/inline_spec.rb +1 -1
  31. data/spec/{asciidoctor → metanorma}/lists_spec.rb +1 -1
  32. data/spec/{asciidoctor → metanorma}/section_spec.rb +1 -1
  33. data/spec/{asciidoctor → metanorma}/validate_spec.rb +1 -1
  34. data/spec/spec_helper.rb +2 -2
  35. metadata +22 -22
@@ -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
File without changes
File without changes
@@ -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
@@ -117,6 +118,26 @@ module Asciidoctor
117
118
  end
118
119
 
119
120
  def image_name_validate(xmldoc); end
121
+
122
+ def toc_cleanup(xmldoc)
123
+ toc_iev_cleanup(xmldoc) if @is_iev
124
+ super
125
+ end
126
+
127
+ def toc_iev_cleanup(xmldoc)
128
+ iev_variant_titles(xmldoc)
129
+ end
130
+
131
+ def iev_variant_titles(xmldoc)
132
+ id = xmldoc&.at("//bibdata/docidentifier[@type = 'ISO']")&.text
133
+ m = /60050-(\d+)/.match(id) or return
134
+ xmldoc.xpath("//sections/clause/terms/title").each_with_index do |t, i|
135
+ num = "%02d" % [i + 1]
136
+ t.next = "<variant-title type='toc'>"\
137
+ "#{@i18n.section_iev} #{m[1]}-#{num} &#x2013; "\
138
+ "#{t.children.to_xml}</variant-title>"
139
+ end
140
+ end
120
141
  end
121
142
  end
122
143
  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,19 @@
32
32
  <ref name="DocumentType"/>
33
33
  </element>
34
34
  </define>
35
+ <define name="bibitem">
36
+ <element name="bibitem">
37
+ <attribute name="id">
38
+ <data type="ID"/>
39
+ </attribute>
40
+ <optional>
41
+ <attribute name="hidden">
42
+ <data type="boolean"/>
43
+ </attribute>
44
+ </optional>
45
+ <ref name="BibliographicItem"/>
46
+ </element>
47
+ </define>
35
48
  <define name="section-title">
36
49
  <element name="title">
37
50
  <zeroOrMore>
@@ -690,6 +703,7 @@
690
703
  <ref name="terms"/>
691
704
  <ref name="term-clause"/>
692
705
  <ref name="definitions"/>
706
+ <ref name="floating-title"/>
693
707
  </choice>
694
708
  </oneOrMore>
695
709
  </element>
@@ -1680,6 +1694,7 @@
1680
1694
  <ref name="clause-subsection"/>
1681
1695
  <ref name="terms"/>
1682
1696
  <ref name="definitions"/>
1697
+ <ref name="floating-title"/>
1683
1698
  </choice>
1684
1699
  </oneOrMore>
1685
1700
  </choice>
@@ -1722,6 +1737,7 @@
1722
1737
  <ref name="terms"/>
1723
1738
  <ref name="definitions"/>
1724
1739
  <ref name="references"/>
1740
+ <ref name="floating-title"/>
1725
1741
  </choice>
1726
1742
  </zeroOrMore>
1727
1743
  </group>
@@ -2534,4 +2550,17 @@
2534
2550
  </oneOrMore>
2535
2551
  </element>
2536
2552
  </define>
2553
+ <define name="floating-title">
2554
+ <element name="floating-title">
2555
+ <attribute name="id">
2556
+ <data type="ID"/>
2557
+ </attribute>
2558
+ <attribute name="depth">
2559
+ <data type="int"/>
2560
+ </attribute>
2561
+ <zeroOrMore>
2562
+ <ref name="TextElement"/>
2563
+ </zeroOrMore>
2564
+ </element>
2565
+ </define>
2537
2566
  </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.0".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"
@@ -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