metanorma-iso 1.3.6 → 1.3.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b990d016a143d3d99c2d7effe05e237661bbfa046b31c5fae6af14ea6f9695f
4
- data.tar.gz: d68fca0b2023046eae06bf883ef7dc8569da86c0ab9a249a108eed75d87388b5
3
+ metadata.gz: 7f3ac994687043ccc35d6421913c9abe3342c3ee4ea17d318f0446b7cc042958
4
+ data.tar.gz: 03b2ccb9739ee87347cd5c58e91eae9b2ad7a64061908d2e898f2d9b054d029b
5
5
  SHA512:
6
- metadata.gz: d9e291ec902643bd28b8d164d4631f015782198ec855597d6c731deb11a87409d9d8ca3fbd586e83b9c1ce98c51d4eab124b4172448c749895811850d3f215d9
7
- data.tar.gz: '049a3e2452504bd12829c34d2fe983c2a42b240191beb9a992d2d478f38a39391b1fbd413a01b181e4496c3ab4bf904b3b7231596ab77d230df69506862d5477'
6
+ metadata.gz: 30d3582ecc68ae76c321e6ea2923dbb28df65c6a024544cacad6c4ebec6f9a554099024544176d931b616d74cfafefd4e0d21296d0c1602aa939c749c85edfe4
7
+ data.tar.gz: 6e9b4a576472188de3b17f090d4fe192bf8247a9cae4039d3d2466c578764d32552f0929db521384777f9acdfda7e0a205de886ccfcd6080dec69ed201bad3cc
@@ -1,11 +1,11 @@
1
1
  = Metanorma-ISO: Metanorma processor for ISO standards
2
2
 
3
3
  image:https://img.shields.io/gem/v/metanorma-iso.svg["Gem Version", link="https://rubygems.org/gems/metanorma-iso"]
4
- image:https://img.shields.io/travis/metanorma/metanorma-iso/master.svg["Build Status", link="https://travis-ci.org/metanorma/metanorma-iso"]
5
- image:https://ci.appveyor.com/api/projects/status/hnc1wnc8i9nquqqb?svg=true["Appveyor Build Status", link="https://ci.appveyor.com/project/ribose/metanorma-iso"]
4
+ image:https://travis-ci.com/metanorma/metanorma-iso.svg["Build Status", link="https://travis-ci.com/metanorma/metanorma-iso"]
5
+ image:https://ci.appveyor.com/api/projects/status/t874i1cbarhnrwki?svg=true["Appveyor Build Status", link="https://ci.appveyor.com/project/metanorma/metanorma-iso"]
6
6
  image:https://codeclimate.com/github/metanorma/metanorma-iso/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/metanorma-iso"]
7
-
8
- WARNING: This gem is still under development.
7
+ image:https://img.shields.io/github/issues-pr-raw/metanorma/metanorma-iso.svg["Pull Requests", link="https://github.com/metanorma/metanorma-iso/pulls"]
8
+ image:https://img.shields.io/github/commits-since/metanorma/metanorma-iso/latest.svg["Commits since latest",link="https://github.com/metanorma/metanorma-iso/releases"]
9
9
 
10
10
  _Formerly known as_ `asciidoctor-iso`.
11
11
 
@@ -341,11 +341,6 @@
341
341
  </oneOrMore>
342
342
  </element>
343
343
  </define>
344
- <define name="tclass">
345
- <element name="name">
346
- <text/>
347
- </element>
348
- </define>
349
344
  <define name="thead">
350
345
  <element name="thead">
351
346
  <ref name="tr"/>
@@ -515,19 +510,22 @@
515
510
  <attribute name="subsequence"/>
516
511
  </optional>
517
512
  <optional>
518
- <ref name="source"/>
513
+ <attribute name="class"/>
519
514
  </optional>
520
515
  <optional>
521
- <ref name="tname"/>
516
+ <ref name="source"/>
522
517
  </optional>
523
518
  <optional>
524
- <ref name="tclass"/>
519
+ <ref name="tname"/>
525
520
  </optional>
526
521
  <choice>
527
522
  <ref name="image"/>
528
523
  <ref name="video"/>
529
524
  <ref name="audio"/>
530
525
  <ref name="pre"/>
526
+ <oneOrMore>
527
+ <ref name="paragraph-with-footnote"/>
528
+ </oneOrMore>
531
529
  <zeroOrMore>
532
530
  <ref name="figure"/>
533
531
  </zeroOrMore>
@@ -2,106 +2,14 @@ require "metanorma-standoc"
2
2
  require_relative "./validate_style.rb"
3
3
  require_relative "./validate_requirements.rb"
4
4
  require_relative "./validate_section.rb"
5
+ require_relative "./validate_title.rb"
5
6
  require "nokogiri"
6
7
  require "jing"
7
- require "pp"
8
8
  require "iev"
9
9
 
10
10
  module Asciidoctor
11
11
  module ISO
12
12
  class Converter < Standoc::Converter
13
- def title_intro_validate(root)
14
- title_intro_en = root.at("//title[@type='title-intro' and @language='en']")
15
- title_intro_fr = root.at("//title[@type='title-intro' and @language='fr']")
16
- if title_intro_en.nil? && !title_intro_fr.nil?
17
- warn "No English Title Intro!"
18
- end
19
- if !title_intro_en.nil? && title_intro_fr.nil?
20
- warn "No French Title Intro!"
21
- end
22
- end
23
-
24
- def title_main_validate(root)
25
- title_main_en = root.at("//title[@type='title-main' and @language='en']")
26
- title_main_fr = root.at("//title[@type='title-main' and @language='fr']")
27
- if title_main_en.nil? && !title_main_fr.nil?
28
- warn "No English Title!"
29
- end
30
- if !title_main_en.nil? && title_main_fr.nil?
31
- warn "No French Title!"
32
- end
33
- end
34
-
35
- def title_part_validate(root)
36
- title_part_en = root.at("//title[@type='title-part' and @language='en']")
37
- title_part_fr = root.at("//title[@type='title-part' and @language='fr']")
38
- (title_part_en.nil? && !title_part_fr.nil?) &&
39
- warn("No English Title Part!")
40
- (!title_part_en.nil? && title_part_fr.nil?) &&
41
- warn("No French Title Part!")
42
- end
43
-
44
- # ISO/IEC DIR 2, 11.4
45
- def title_subpart_validate(root)
46
- docid = root.at("//bibdata/docidentifier[@type = 'iso']")
47
- subpart = /-\d+-\d+/.match docid
48
- iec = root.at("//bibdata/contributor[role/@type = 'publisher']/"\
49
- "organization[abbreviation = 'IEC' or "\
50
- "name = 'International Electrotechnical Commission']")
51
- warn("Subpart defined on non-IEC document!") if subpart && !iec
52
- end
53
-
54
- # ISO/IEC DIR 2, 11.5.2
55
- def title_names_type_validate(root)
56
- doctypes = /International\sStandard | Technical\sSpecification |
57
- Publicly\sAvailable\sSpecification | Technical\sReport | Guide /xi
58
- title_main_en = root.at("//title[@type='title-main' and @language='en']")
59
- if !title_main_en.nil? && doctypes.match(title_main_en.text)
60
- warn "Main Title may name document type"
61
- end
62
- title_intro_en = root.at("//title[@type='title-intro' and @language='en']")
63
- if !title_intro_en.nil? && doctypes.match(title_intro_en.text)
64
- warn "Title Intro may name document type"
65
- end
66
- end
67
-
68
- # ISO/IEC DIR 2, 22.2
69
- def title_first_level_validate(root)
70
- root.xpath(SECTIONS_XPATH).each do |s|
71
- title = s&.at("./title")&.text || s.name
72
- s.xpath("./clause | ./terms | ./references").each do |ss|
73
- subtitle = ss.at("./title")
74
- !subtitle.nil? && !subtitle&.text&.empty? ||
75
- warn("#{title}: each first-level subclause must have a title")
76
- end
77
- end
78
- end
79
-
80
- # ISO/IEC DIR 2, 22.2
81
- def title_all_siblings(xpath, label)
82
- notitle = false
83
- withtitle = false
84
- xpath.each do |s|
85
- title_all_siblings(s.xpath("./clause | ./terms | ./references"),
86
- s&.at("./title")&.text || s["id"])
87
- subtitle = s.at("./title")
88
- notitle = notitle || (!subtitle || subtitle.text.empty?)
89
- withtitle = withtitle || (subtitle && !subtitle.text.empty?)
90
- end
91
- notitle && withtitle &&
92
- warn("#{label}: all subclauses must have a title, or none")
93
- end
94
-
95
- def title_validate(root)
96
- title_intro_validate(root)
97
- title_main_validate(root)
98
- title_part_validate(root)
99
- title_subpart_validate(root)
100
- title_names_type_validate(root)
101
- title_first_level_validate(root)
102
- title_all_siblings(root.xpath(SECTIONS_XPATH), "(top level)")
103
- end
104
-
105
13
  # ISO/IEC DIR 2, 22.3.2
106
14
  def onlychild_clause_validate(root)
107
15
  root.xpath(Standoc::Utils::SUBCLAUSE_XPATH).each do |c|
@@ -245,6 +153,19 @@ module Asciidoctor
245
153
  see_erefs_validate(doc.root)
246
154
  locality_erefs_validate(doc.root)
247
155
  bibdata_validate(doc.root)
156
+ bibitem_validate(doc.root)
157
+ end
158
+
159
+ def bibitem_validate(xmldoc)
160
+ xmldoc.xpath("//bibitem[date/on = '--']").each do |b|
161
+ found = false
162
+ b.xpath("./note").each do |n|
163
+ found = true if /^ISO DATE:/.match n.text
164
+ end
165
+ found or
166
+ warn "Reference #{b&.at("./@id")&.text} does not have an "\
167
+ "associated footnote indicating unpublished status"
168
+ end
248
169
  end
249
170
 
250
171
  def validate(doc)
@@ -0,0 +1,99 @@
1
+ require "metanorma-standoc"
2
+
3
+ module Asciidoctor
4
+ module ISO
5
+ class Converter < Standoc::Converter
6
+ def title_intro_validate(root)
7
+ title_intro_en = root.at("//title[@type='title-intro' and @language='en']")
8
+ title_intro_fr = root.at("//title[@type='title-intro' and @language='fr']")
9
+ if title_intro_en.nil? && !title_intro_fr.nil?
10
+ warn "No English Title Intro!"
11
+ end
12
+ if !title_intro_en.nil? && title_intro_fr.nil?
13
+ warn "No French Title Intro!"
14
+ end
15
+ end
16
+
17
+ def title_main_validate(root)
18
+ title_main_en = root.at("//title[@type='title-main' and @language='en']")
19
+ title_main_fr = root.at("//title[@type='title-main' and @language='fr']")
20
+ if title_main_en.nil? && !title_main_fr.nil?
21
+ warn "No English Title!"
22
+ end
23
+ if !title_main_en.nil? && title_main_fr.nil?
24
+ warn "No French Title!"
25
+ end
26
+ end
27
+
28
+ def title_part_validate(root)
29
+ title_part_en = root.at("//title[@type='title-part' and @language='en']")
30
+ title_part_fr = root.at("//title[@type='title-part' and @language='fr']")
31
+ (title_part_en.nil? && !title_part_fr.nil?) &&
32
+ warn("No English Title Part!")
33
+ (!title_part_en.nil? && title_part_fr.nil?) &&
34
+ warn("No French Title Part!")
35
+ end
36
+
37
+ # ISO/IEC DIR 2, 11.4
38
+ def title_subpart_validate(root)
39
+ docid = root.at("//bibdata/docidentifier[@type = 'iso']")
40
+ subpart = /-\d+-\d+/.match docid
41
+ iec = root.at("//bibdata/contributor[role/@type = 'publisher']/"\
42
+ "organization[abbreviation = 'IEC' or "\
43
+ "name = 'International Electrotechnical Commission']")
44
+ warn("Subpart defined on non-IEC document!") if subpart && !iec
45
+ end
46
+
47
+ # ISO/IEC DIR 2, 11.5.2
48
+ def title_names_type_validate(root)
49
+ doctypes = /International\sStandard | Technical\sSpecification |
50
+ Publicly\sAvailable\sSpecification | Technical\sReport | Guide /xi
51
+ title_main_en = root.at("//title[@type='title-main' and @language='en']")
52
+ if !title_main_en.nil? && doctypes.match(title_main_en.text)
53
+ warn "Main Title may name document type"
54
+ end
55
+ title_intro_en = root.at("//title[@type='title-intro' and @language='en']")
56
+ if !title_intro_en.nil? && doctypes.match(title_intro_en.text)
57
+ warn "Title Intro may name document type"
58
+ end
59
+ end
60
+
61
+ # ISO/IEC DIR 2, 22.2
62
+ def title_first_level_validate(root)
63
+ root.xpath(SECTIONS_XPATH).each do |s|
64
+ title = s&.at("./title")&.text || s.name
65
+ s.xpath("./clause | ./terms | ./references").each do |ss|
66
+ subtitle = ss.at("./title")
67
+ !subtitle.nil? && !subtitle&.text&.empty? ||
68
+ warn("#{title}: each first-level subclause must have a title")
69
+ end
70
+ end
71
+ end
72
+
73
+ # ISO/IEC DIR 2, 22.2
74
+ def title_all_siblings(xpath, label)
75
+ notitle = false
76
+ withtitle = false
77
+ xpath.each do |s|
78
+ title_all_siblings(s.xpath("./clause | ./terms | ./references"),
79
+ s&.at("./title")&.text || s["id"])
80
+ subtitle = s.at("./title")
81
+ notitle = notitle || (!subtitle || subtitle.text.empty?)
82
+ withtitle = withtitle || (subtitle && !subtitle.text.empty?)
83
+ end
84
+ notitle && withtitle &&
85
+ warn("#{label}: all subclauses must have a title, or none")
86
+ end
87
+
88
+ def title_validate(root)
89
+ title_intro_validate(root)
90
+ title_main_validate(root)
91
+ title_part_validate(root)
92
+ title_subpart_validate(root)
93
+ title_names_type_validate(root)
94
+ title_first_level_validate(root)
95
+ title_all_siblings(root.xpath(SECTIONS_XPATH), "(top level)")
96
+ end
97
+ end
98
+ end
99
+ end
@@ -15,6 +15,23 @@ p.Sourcecode, li.Sourcecode, div.Sourcecode, pre.Sourcecode
15
15
  mso-fareast-font-family:Calibri;
16
16
  mso-bidi-font-family:"Courier New";
17
17
  mso-ansi-language:EN-GB;}
18
+ p.pseudocode, li.pseudocode, div.pseudocode
19
+ {mso-style-unhide:no;
20
+ mso-style-qformat:yes;
21
+ mso-style-parent:"";
22
+ margin-top:0cm;
23
+ margin-right:0cm;
24
+ margin-bottom:12.0pt;
25
+ margin-left:0cm;
26
+ text-align:left;
27
+ line-height:12.0pt;
28
+ mso-pagination:widow-orphan;
29
+ tab-stops:20.15pt;
30
+ font-size:9.0pt;
31
+ font-family:$bodyfont;
32
+ mso-fareast-font-family:Calibri;
33
+ mso-bidi-font-family:"Courier New";
34
+ mso-ansi-language:EN-GB;}
18
35
  p.Biblio, li.Biblio, div.Biblio
19
36
  {mso-style-unhide:no;
20
37
  mso-style-qformat:yes;
@@ -738,6 +755,10 @@ div.example p.MsoListParagraph {
738
755
  font-size: 10.0pt;
739
756
  }
740
757
 
758
+ div.Note p.MsoListParagraph {
759
+ font-size: 10.0pt;
760
+ }
761
+
741
762
  span.note_label, span.example_label, td.example_label, td.note_label
742
763
  {
743
764
  font-size: 10.0pt;
@@ -627,7 +627,7 @@ font-family: $monospacefont;
627
627
  font-variant-ligatures: none;
628
628
  }
629
629
 
630
- .figure, .Sourcecode {
630
+ .figure, .Sourcecode, .pseudocode {
631
631
  background-color: #f7f7f7;
632
632
  line-height: 1.6em;
633
633
  padding: 1.5em;
@@ -694,7 +694,7 @@ margin-left:-1.5em;
694
694
  }
695
695
 
696
696
 
697
- .example .Sourcecode {
697
+ .example .Sourcecode, .example .pseudocode {
698
698
  background: none;
699
699
  }
700
700
 
@@ -620,7 +620,7 @@ font-family: $monospacefont;
620
620
  font-variant-ligatures: none;
621
621
  }
622
622
 
623
- .figure, .Sourcecode {
623
+ .figure, .Sourcecode, .pseudocode {
624
624
  background-color: #f7f7f7;
625
625
  line-height: 1.6em;
626
626
  padding: 1.5em;
@@ -685,7 +685,7 @@ margin-top:0;
685
685
  }
686
686
 
687
687
 
688
- .example .Sourcecode {
688
+ .example .Sourcecode, .example .pseudocode {
689
689
  background: none;
690
690
  }
691
691
 
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ISO
3
- VERSION = "1.3.6".freeze
3
+ VERSION = "1.3.7".freeze
4
4
  end
5
5
  end
@@ -29,7 +29,6 @@ Gem::Specification.new do |spec|
29
29
  spec.test_files = `git ls-files -- {spec}/*`.split("\n")
30
30
  spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
31
31
 
32
- spec.add_dependency "asciidoctor", "~> 1.5.7"
33
32
  spec.add_dependency "ruby-jing"
34
33
  spec.add_dependency "isodoc", "~> 1.0.0"
35
34
  spec.add_dependency "metanorma-standoc", "~> 1.3.0"
@@ -11,14 +11,14 @@ RSpec.describe Asciidoctor::ISO do
11
11
  #FileUtils.cd "spec/examples"
12
12
  #Asciidoctor.convert_file "rice.adoc", {:attributes=>{"backend"=>"iso"}, :safe=>0, :header_footer=>true, :requires=>["metanorma-iso"], :failure_level=>4, :mkdirs=>true, :to_file=>nil}
13
13
  #FileUtils.cd "../.."
14
- #expect(File.exist?("spec/examples/rice.xml")).to be true
15
- #expect(File.exist?("spec/examples/rice.doc")).to be true
16
- #expect(File.exist?("spec/examples/rice.html")).to be true
17
- #expect(File.exist?("spec/examples/rice_alt.html")).to be true
14
+ #expect(File.exist?("spec/examples/rice.xml"))).to be true
15
+ #expect(File.exist?("spec/examples/rice.doc"))).to be true
16
+ #expect(File.exist?("spec/examples/rice.html"))).to be true
17
+ #expect(File.exist?("spec/examples/rice_alt.html"))).to be true
18
18
  #end
19
19
 
20
20
  it "processes a blank document" do
21
- expect(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)).to be_equivalent_to <<~"OUTPUT"
21
+ expect(xmlpp(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
22
22
  #{ASCIIDOC_BLANK_HDR}
23
23
  INPUT
24
24
  #{BLANK_HDR}
@@ -29,7 +29,7 @@ RSpec.describe Asciidoctor::ISO do
29
29
 
30
30
  it "converts a blank document" do
31
31
  FileUtils.rm_f "test.doc"
32
- expect(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)).to be_equivalent_to <<~"OUTPUT"
32
+ expect(xmlpp(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
33
33
  = Document title
34
34
  Author
35
35
  :docfile: test.adoc
@@ -45,7 +45,7 @@ RSpec.describe Asciidoctor::ISO do
45
45
  end
46
46
 
47
47
  it "processes default metadata" do
48
- expect(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)).to be_equivalent_to <<~"OUTPUT"
48
+ expect(xmlpp(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
49
49
  = Document title
50
50
  Author
51
51
  :docfile: test.adoc
@@ -168,7 +168,7 @@ RSpec.describe Asciidoctor::ISO do
168
168
 
169
169
 
170
170
  it "processes complex metadata" do
171
- expect(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)).to be_equivalent_to <<~'OUTPUT'
171
+ expect(xmlpp(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~'OUTPUT'
172
172
  = Document title
173
173
  Author
174
174
  :docfile: test.adoc
@@ -280,7 +280,7 @@ RSpec.describe Asciidoctor::ISO do
280
280
  end
281
281
 
282
282
  it "defaults substage" do
283
- expect(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)).to be_equivalent_to <<~"OUTPUT"
283
+ expect(xmlpp(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
284
284
  = Document title
285
285
  Author
286
286
  :docfile: test.adoc
@@ -342,7 +342,7 @@ OUTPUT
342
342
  end
343
343
 
344
344
  it "defaults substage for stage 60" do
345
- expect(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)).to be_equivalent_to <<~"OUTPUT"
345
+ expect(xmlpp(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
346
346
  = Document title
347
347
  Author
348
348
  :docfile: test.adoc
@@ -404,7 +404,7 @@ OUTPUT
404
404
  end
405
405
 
406
406
  it "populates metadata for PRF" do
407
- expect(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)).to be_equivalent_to <<~"OUTPUT"
407
+ expect(xmlpp(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
408
408
  = Document title
409
409
  Author
410
410
  :docfile: test.adoc