metanorma-iso 1.5.1 → 1.5.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,6 +3,93 @@ require "fileutils"
3
3
 
4
4
  RSpec.describe Asciidoctor::ISO do
5
5
 
6
+ it "Warns of missing scope" do
7
+ FileUtils.rm_f "test.err"
8
+ Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
9
+ = Document title
10
+ Author
11
+ :docfile: test.adoc
12
+ :nodoc:
13
+ :no-isobib:
14
+ :doctype: pizza
15
+
16
+ text
17
+ INPUT
18
+ expect(File.read("test.err")).to include "Scope clause missing"
19
+ FileUtils.rm_f "test.err"
20
+ Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
21
+ = Document title
22
+ Author
23
+ :docfile: test.adoc
24
+ :nodoc:
25
+ :no-isobib:
26
+ :doctype: pizza
27
+
28
+ == Scope
29
+ INPUT
30
+ expect(File.read("test.err")).not_to include "Scope clause missing"
31
+
32
+ end
33
+
34
+ it "Warns of missing normative references" do
35
+ FileUtils.rm_f "test.err"
36
+ Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
37
+ = Document title
38
+ Author
39
+ :docfile: test.adoc
40
+ :nodoc:
41
+ :no-isobib:
42
+ :doctype: pizza
43
+
44
+ text
45
+ INPUT
46
+ expect(File.read("test.err")).to include "Normative references missing"
47
+ FileUtils.rm_f "test.err"
48
+ Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
49
+ = Document title
50
+ Author
51
+ :docfile: test.adoc
52
+ :nodoc:
53
+ :no-isobib:
54
+ :doctype: pizza
55
+
56
+ [bibliography]
57
+ == Normative references
58
+ INPUT
59
+ expect(File.read("test.err")).not_to include "Normative references missing"
60
+
61
+ end
62
+
63
+ it "Warns of missing terms & definitions" do
64
+ FileUtils.rm_f "test.err"
65
+ Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
66
+ = Document title
67
+ Author
68
+ :docfile: test.adoc
69
+ :nodoc:
70
+ :no-isobib:
71
+ :doctype: pizza
72
+
73
+ text
74
+ INPUT
75
+ expect(File.read("test.err")).to include "Terms & definitions missing"
76
+ FileUtils.rm_f "test.err"
77
+ Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
78
+ = Document title
79
+ Author
80
+ :docfile: test.adoc
81
+ :nodoc:
82
+ :no-isobib:
83
+ :doctype: pizza
84
+
85
+ == Terms and definitions
86
+ === Term 1
87
+ INPUT
88
+ expect(File.read("test.err")).not_to include "Terms & definitions missing"
89
+
90
+ end
91
+
92
+
6
93
  it "Warns of illegal doctype" do
7
94
  FileUtils.rm_f "test.err"
8
95
  Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
@@ -66,9 +66,9 @@ RSpec.describe IsoDoc do
66
66
  <preface>
67
67
  <foreword>
68
68
  <p>
69
- <xref target='N'>[N]</xref>
70
- <xref target='note1'>[note1]</xref>
71
- <xref target='note2'>[note2]</xref>
69
+ <xref target='N'>[scope], Note</xref>
70
+ <xref target='note1'>[widgets1], Note 1</xref>
71
+ <xref target='note2'>[widgets1], Note 2</xref>
72
72
  <xref target='AN'>A.1, Note</xref>
73
73
  <xref target='Anote1'>A.2, Note 1</xref>
74
74
  <xref target='Anote2'>A.2, Note 2</xref>
@@ -86,7 +86,7 @@ RSpec.describe IsoDoc do
86
86
  </p>
87
87
  </note>
88
88
  <p>
89
- <xref target='N'>[n]</xref>
89
+ <xref target='N'>Note</xref>
90
90
  </p>
91
91
  </clause>
92
92
  <terms id='terms'/>
@@ -94,22 +94,22 @@ RSpec.describe IsoDoc do
94
94
  <title depth="1">Widgets</title>
95
95
  <clause id='widgets1' inline-header="true">
96
96
  <note id='note1'>
97
- <name>NOTE</name>
97
+ <name>NOTE 1</name>
98
98
  <p id='_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f'>
99
99
  These results are based on a study carried out on three different
100
100
  types of kernel.
101
101
  </p>
102
102
  </note>
103
103
  <note id='note2'>
104
- <name>NOTE</name>
104
+ <name>NOTE 2</name>
105
105
  <p id='_f06fd0d1-a203-4f3d-a515-0bdba0f8d83a'>
106
106
  These results are based on a study carried out on three different
107
107
  types of kernel.
108
108
  </p>
109
109
  </note>
110
110
  <p>
111
- <xref target='note1'>[note1]</xref>
112
- <xref target='note2'>[note2]</xref>
111
+ <xref target='note1'>Note 1</xref>
112
+ <xref target='note2'>Note 2</xref>
113
113
  </p>
114
114
  </clause>
115
115
  </clause>
@@ -229,8 +229,8 @@ RSpec.describe IsoDoc do
229
229
  <title>Foreword</title>
230
230
  <p id='A'>
231
231
  This is a preamble
232
- <xref target='C'>[C]</xref>
233
- <xref target='C1'>[C1]</xref>
232
+ <xref target='C'>0.1</xref>
233
+ <xref target='C1'>0.2</xref>
234
234
  <xref target='D'>[D]</xref>
235
235
  <xref target='H'>[H]</xref>
236
236
  <xref target='I'>[I]</xref>
@@ -250,7 +250,7 @@ RSpec.describe IsoDoc do
250
250
  <introduction id='B' obligation='informative'>
251
251
  <title depth="1">Introduction</title>
252
252
  <clause id='C' inline-header='false' obligation='informative'>
253
- <title depth="1">Introduction Subsection</title>
253
+ <title depth="2">Introduction Subsection</title>
254
254
  </clause>
255
255
  <clause id='C1' inline-header='true' obligation='informative'>Text</clause>
256
256
  </introduction>
@@ -435,7 +435,7 @@ RSpec.describe IsoDoc do
435
435
  <introduction id='B' obligation='informative'>
436
436
  <title depth='1'>Introduction</title>
437
437
  <clause id='C' inline-header='false' obligation='informative'>
438
- <title depth='1'>Introduction Subsection</title>
438
+ <title depth='2'>Introduction Subsection</title>
439
439
  </clause>
440
440
  </introduction>
441
441
  <clause id='B1'>
@@ -548,7 +548,7 @@ RSpec.describe IsoDoc do
548
548
  <div class='Section3' id='B'>
549
549
  <h1 class='IntroTitle'>Introduction</h1>
550
550
  <div id='C'>
551
- <h1>Introduction Subsection</h1>
551
+ <h2>Introduction Subsection</h2>
552
552
  </div>
553
553
  </div>
554
554
  <br/>
@@ -271,7 +271,7 @@ end
271
271
  <h1 class="ForewordTitle">Foreword</h1>
272
272
  <div id="samplecode" class="example">
273
273
  <p><span class="example_label">EXAMPLE 1</span>&#160; </p>
274
- <div class="Quote">Hello<p class="QuoteAttribution"/></div>
274
+ <div class="Quote">Hello</div>
275
275
  </div>
276
276
  <div id="samplecode2" class="example">
277
277
  <p><span class="example_label">EXAMPLE 2&#160;&#8212; Title</span>&#160; Hello</p>
@@ -330,7 +330,7 @@ end
330
330
 
331
331
 
332
332
  it "processes sequences of examples (Word)" do
333
- expect(IsoDoc::Iso::WordConvert.new({}).convert("test", <<~"INPUT", true).sub(/^.*<body/m, "<body").sub(%r{</body>.*$}m, "</body>")).to be_equivalent_to <<~"OUTPUT"
333
+ expect(xmlpp(IsoDoc::Iso::WordConvert.new({}).convert("test", <<~"INPUT", true).sub(/^.*<body/m, "<body").sub(%r{</body>.*$}m, "</body>"))).to be_equivalent_to xmlpp(<<~"OUTPUT")
334
334
  <iso-standard xmlns='http://riboseinc.com/isoxml'>
335
335
  <preface>
336
336
  <foreword>
@@ -361,7 +361,7 @@ end
361
361
  <h1 class="ForewordTitle">Foreword</h1>
362
362
  <div id="samplecode" class="example">
363
363
  <p><span class="example_label">EXAMPLE 1</span><span style="mso-tab-count:1">&#160; </span></p>
364
- <div class="Quote">Hello<p class="QuoteAttribution"/></div>
364
+ <div class="Quote">Hello</div>
365
365
  </div>
366
366
  <div id="samplecode2" class="example">
367
367
  <p><span class="example_label">EXAMPLE 2&#160;&#8212; Title</span><span style="mso-tab-count:1">&#160; </span>Hello</p>
@@ -215,7 +215,7 @@ RSpec.describe IsoDoc do
215
215
  expect(xmlpp("<div>" + word.gsub(/_Toc\d\d+/, "_Toc") )).to be_equivalent_to xmlpp(<<~'OUTPUT')
216
216
  <div>
217
217
  <p class="MsoToc1"><span lang="EN-GB" xml:lang="EN-GB"><span style="mso-element:field-begin"></span><span style="mso-spacerun:yes">&#xA0;</span>TOC
218
- \o "1-2" \h \z \u <span style="mso-element:field-separator"></span></span>
218
+ \o "1-3" \h \z \u <span style="mso-element:field-separator"></span></span>
219
219
  <span class="MsoHyperlink"><span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
220
220
  <a href="#_Toc">1 Clause 4<span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
221
221
  <span style="mso-tab-count:1 dotted">. </span>
@@ -705,4 +705,79 @@ expect((IsoDoc::Iso::PresentationXMLConvert.new({wordstylesheet: "spec/assets/wo
705
705
  expect(word).to include '<p class="zzWarning">This document is not an ISO International Standard'
706
706
  end
707
707
 
708
+ it "populates Word ToC" do
709
+ FileUtils.rm_f "test.doc"
710
+ IsoDoc::WordConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.scss", wordintropage: "spec/assets/wordintro.html"}).convert("test", <<~"INPUT", false)
711
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
712
+ <sections>
713
+ <clause id="A" inline-header="false" obligation="normative"><title>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
714
+ <title>Introduction<bookmark id="Q"/> to this<fn reference="1">
715
+ <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p>
716
+ </fn></title>
717
+ </clause>
718
+ <clause id="O" inline-header="false" obligation="normative">
719
+ <title>Clause 4.2</title>
720
+ <p>A<fn reference="1">
721
+ <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p>
722
+ </fn></p>
723
+ <clause id="P" inline-header="false" obligation="normative">
724
+ <title>Clause 4.2.1</title>
725
+ </clause>
726
+ </clause></clause>
727
+ </sections>
728
+ </iso-standard>
729
+ INPUT
730
+ word = File.read("test.doc").sub(/^.*<div class="WordSection2">/m, '<div class="WordSection2">').
731
+ sub(%r{<p class="MsoNormal">\s*<br clear="all" class="section"/>\s*</p>\s*<div class="WordSection3">.*$}m, "")
732
+ expect(xmlpp(word.gsub(/_Toc\d\d+/, "_Toc"))).to be_equivalent_to xmlpp(<<~'OUTPUT')
733
+ <div class="WordSection2">
734
+ An empty word intro page.
735
+
736
+ <p class="MsoToc1"><span lang="EN-GB" xml:lang="EN-GB"><span style="mso-element:field-begin"></span><span style="mso-spacerun:yes">&#xA0;</span>TOC
737
+ \o "1-2" \h \z \u <span style="mso-element:field-separator"></span></span>
738
+ <span class="MsoHyperlink"><span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
739
+ <a href="#_Toc">Clause 4<span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
740
+ <span style="mso-tab-count:1 dotted">. </span>
741
+ </span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
742
+ <span style="mso-element:field-begin"></span></span>
743
+ <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"> PAGEREF _Toc \h </span>
744
+ <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-separator"></span></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">1</span>
745
+ <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-end"></span></span></a></span></span></p>
746
+ <p class="MsoToc2">
747
+ <span class="MsoHyperlink">
748
+ <span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
749
+ <a href="#_Toc">Introduction to this<span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
750
+ <span style="mso-tab-count:1 dotted">. </span>
751
+ </span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
752
+ <span style="mso-element:field-begin"></span></span>
753
+ <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"> PAGEREF _Toc \h </span>
754
+ <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-separator"></span></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">1</span>
755
+ <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-end"></span></span></a></span>
756
+ </span>
757
+ </p>
758
+ <p class="MsoToc2">
759
+ <span class="MsoHyperlink">
760
+ <span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
761
+ <a href="#_Toc">Clause 4.2<span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
762
+ <span style="mso-tab-count:1 dotted">. </span>
763
+ </span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
764
+ <span style="mso-element:field-begin"></span></span>
765
+ <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"> PAGEREF _Toc \h </span>
766
+ <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-separator"></span></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">1</span>
767
+ <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-end"></span></span></a></span>
768
+ </span>
769
+ </p>
770
+ <p class="MsoToc1">
771
+ <span lang="EN-GB" xml:lang="EN-GB">
772
+ <span style="mso-element:field-end"></span>
773
+ </span>
774
+ <span lang="EN-GB" xml:lang="EN-GB">
775
+ <p class="MsoNormal">&#xA0;</p>
776
+ </span>
777
+ </p>
778
+ <p class="MsoNormal">&#xA0;</p>
779
+ </div>
780
+ OUTPUT
781
+ end
782
+
708
783
  end
@@ -1,7 +1,7 @@
1
1
  require "spec_helper"
2
2
 
3
3
  RSpec.describe IsoDoc do
4
- it "processes IsoXML bibliographies (Presentation XML)" do
4
+ it "processes IsoXML bibliographies" do
5
5
  input = <<~INPUT
6
6
  <iso-standard xmlns="http://riboseinc.com/isoxml">
7
7
  <bibdata>
@@ -15,7 +15,7 @@ RSpec.describe Metanorma::Iso::Processor do
15
15
 
16
16
  it "registers output formats against metanorma" do
17
17
  expect(processor.output_formats.sort.to_s).to be_equivalent_to <<~"OUTPUT"
18
- [[:doc, "doc"], [:html, "html"], [:html_alt, "alt.html"], [:pdf, "pdf"], [:presentation, "presentation.xml"], [:rxl, "rxl"], [:sts, "sts.xml"], [:xml, "xml"]]
18
+ [[:doc, "doc"], [:html, "html"], [:html_alt, "alt.html"], [:isosts, "sts.xml"], [:pdf, "pdf"], [:presentation, "presentation.xml"], [:rxl, "rxl"], [:sts, "sts.xml"], [:xml, "xml"]]
19
19
  OUTPUT
20
20
  end
21
21
 
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: 1.5.1
4
+ version: 1.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-29 00:00:00.000000000 Z
11
+ date: 2020-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-jing
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 1.2.0
89
+ version: 1.5.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 1.2.0
96
+ version: 1.5.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: byebug
99
99
  requirement: !ruby/object:Gem::Requirement