metanorma-iec 1.4.2 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,191 +3,200 @@ require "spec_helper"
3
3
  RSpec.describe IsoDoc do
4
4
  it "processes IsoXML terms" do
5
5
  input = <<~INPUT
6
- <iso-standard xmlns="http://riboseinc.com/isoxml">
7
- <sections>
8
- <terms id="_terms_and_definitions" obligation="normative"><title>Terms and definitions</title>
9
-
10
- <term id="paddy1"><preferred>paddy</preferred>
11
- <domain>rice</domain>
12
- <definition><verbaldefinition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></verbaldefinition></definition>
13
- <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f892">
14
- <p id="_65c9a509-9a89-4b54-a890-274126aeb55c">Foreign seeds, husks, bran, sand, dust.</p>
15
- <ul>
16
- <li>A</li>
17
- </ul>
18
- </termexample>
19
- <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f894">
20
- <ul>
21
- <li>A</li>
22
- </ul>
23
- </termexample>
24
-
25
- <termsource status="modified">
26
- <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality>ISO 7301:2011, 3.1</origin>
27
- <modification>
28
- <p id="_e73a417d-ad39-417d-a4c8-20e4e2529489">The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here</p>
29
- </modification>
30
- </termsource></term>
31
-
32
- <term id="paddy">
33
- <preferred>paddy</preferred><admitted>paddy rice</admitted>
34
- <admitted>rough rice</admitted>
35
- <deprecates>cargo rice</deprecates>
36
- <definition><verbaldefinition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></verbaldefinition></definition>
37
- <termnote id="_671a1994-4783-40d0-bc81-987d06ffb74e">
38
- <p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p>
39
- </termnote>
40
- <termnote id="_671a1994-4783-40d0-bc81-987d06ffb74f">
41
- <ul><li>A</li></ul>
42
- <p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p>
43
- </termnote>
44
- <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f893">
45
- <ul>
46
- <li>A</li>
47
- </ul>
48
- </termexample>
49
- <termsource status="identical">
50
- <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality>ISO 7301:2011, 3.1</origin>
51
- </termsource></term>
52
- </terms>
53
- </sections>
54
- </iso-standard>
6
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
7
+ <sections>
8
+ <terms id="_terms_and_definitions" obligation="normative"><title>Terms and definitions</title>
9
+
10
+ <term id="paddy1"><preferred>paddy</preferred>
11
+ <domain>rice</domain>
12
+ <definition><verbal-definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></verbal-definition></definition>
13
+ <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f892">
14
+ <p id="_65c9a509-9a89-4b54-a890-274126aeb55c">Foreign seeds, husks, bran, sand, dust.</p>
15
+ <ul>
16
+ <li>A</li>
17
+ </ul>
18
+ </termexample>
19
+ <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f894">
20
+ <ul>
21
+ <li>A</li>
22
+ </ul>
23
+ </termexample>
24
+
25
+ <termsource status="modified">
26
+ <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality>ISO 7301:2011, 3.1</origin>
27
+ <modification>
28
+ <p id="_e73a417d-ad39-417d-a4c8-20e4e2529489">The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here</p>
29
+ </modification>
30
+ </termsource></term>
31
+
32
+ <term id="paddy">
33
+ <preferred>paddy</preferred><admitted>paddy rice</admitted>
34
+ <admitted>rough rice</admitted>
35
+ <deprecates>cargo rice</deprecates>
36
+ <definition><verbal-definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></verbal-definition></definition>
37
+ <termnote id="_671a1994-4783-40d0-bc81-987d06ffb74e">
38
+ <p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p>
39
+ </termnote>
40
+ <termnote id="_671a1994-4783-40d0-bc81-987d06ffb74f">
41
+ <ul><li>A</li></ul>
42
+ <p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p>
43
+ </termnote>
44
+ <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f893">
45
+ <ul>
46
+ <li>A</li>
47
+ </ul>
48
+ </termexample>
49
+ <termsource status="identical">
50
+ <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality>ISO 7301:2011, 3.1</origin>
51
+ </termsource></term>
52
+ </terms>
53
+ </sections>
54
+ </iso-standard>
55
55
  INPUT
56
56
  presxml = <<~INPUT
57
- <iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
58
- <sections>
59
- <terms id="_terms_and_definitions" obligation="normative" displayorder="1"><title depth="1">1<tab/>Terms and definitions</title>
60
-
61
- <term id="paddy1">
62
- <name>1.1</name><preferred>paddy</preferred>
63
- <domain>rice</domain>
64
- <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
65
- <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f892">
66
- <name>EXAMPLE 1</name>
67
- <p id="_65c9a509-9a89-4b54-a890-274126aeb55c">Foreign seeds, husks, bran, sand, dust.</p>
68
- <ul>
69
- <li>A</li>
70
- </ul>
71
- </termexample>
72
- <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f894">
73
- <name>EXAMPLE 2</name>
74
- <ul>
75
- <li>A</li>
76
- </ul>
77
- </termexample>
78
-
79
- <termsource status="modified">
80
- <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality>ISO 7301:2011, 3.1</origin>
81
- <modification>
82
- <p id="_e73a417d-ad39-417d-a4c8-20e4e2529489">The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here</p>
83
- </modification>
84
- </termsource></term>
85
-
86
- <term id="paddy">
87
- <name>1.2</name>
88
- <preferred>paddy</preferred><admitted>paddy rice</admitted>
89
- <admitted>rough rice</admitted>
90
- <deprecates>cargo rice</deprecates>
91
- <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
92
- <termnote id="_671a1994-4783-40d0-bc81-987d06ffb74e">
93
- <name>Note 1 to entry</name>
94
- <p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p>
95
- </termnote>
96
- <termnote id="_671a1994-4783-40d0-bc81-987d06ffb74f">
97
- <name>Note 2 to entry</name>
98
- <ul><li>A</li></ul>
99
- <p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p>
100
- </termnote>
101
- <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f893">
102
- <name>EXAMPLE</name>
103
- <ul>
104
- <li>A</li>
105
- </ul>
106
- </termexample>
107
- <termsource status="identical">
108
- <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality>ISO 7301:2011, 3.1</origin>
109
- </termsource></term>
110
- </terms>
111
- </sections>
112
- </iso-standard>
57
+ <?xml version='1.0'?>
58
+ <iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
59
+ <sections>
60
+ <terms id="_terms_and_definitions" obligation="normative" displayorder="1"><title depth="1">1<tab/>Terms and definitions</title>
61
+
62
+ <term id="paddy1">
63
+ <name>1.1</name><preferred>paddy</preferred>
64
+ <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">&#x3c;rice&#x3e; rice retaining its husk after threshing</p></definition>
65
+ <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f892">
66
+ <name>EXAMPLE 1</name>
67
+ <p id="_65c9a509-9a89-4b54-a890-274126aeb55c">Foreign seeds, husks, bran, sand, dust.</p>
68
+ <ul>
69
+ <li>A</li>
70
+ </ul>
71
+ </termexample>
72
+ <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f894">
73
+ <name>EXAMPLE 2</name>
74
+ <ul>
75
+ <li>A</li>
76
+ </ul>
77
+ </termexample>
78
+
79
+ <termsource status="modified">
80
+ <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality>ISO 7301:2011, 3.1</origin>
81
+ <modification>
82
+ <p id="_e73a417d-ad39-417d-a4c8-20e4e2529489">The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here</p>
83
+ </modification>
84
+ </termsource></term>
85
+
86
+ <term id="paddy">
87
+ <name>1.2</name>
88
+ <preferred>paddy</preferred><admitted>paddy rice</admitted>
89
+ <admitted>rough rice</admitted>
90
+ <deprecates>cargo rice</deprecates>
91
+ <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
92
+ <termnote id="_671a1994-4783-40d0-bc81-987d06ffb74e">
93
+ <name>Note 1 to entry</name>
94
+ <p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p>
95
+ </termnote>
96
+ <termnote id="_671a1994-4783-40d0-bc81-987d06ffb74f">
97
+ <name>Note 2 to entry</name>
98
+ <ul><li>A</li></ul>
99
+ <p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p>
100
+ </termnote>
101
+ <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f893">
102
+ <name>EXAMPLE</name>
103
+ <ul>
104
+ <li>A</li>
105
+ </ul>
106
+ </termexample>
107
+ <termsource status="identical">
108
+ <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality>ISO 7301:2011, 3.1</origin>
109
+ </termsource></term>
110
+ </terms>
111
+ </sections>
112
+ </iso-standard>
113
113
  INPUT
114
114
  html = <<~OUTPUT
115
- #{HTML_HDR}
116
- <div id="">
117
- <h1 class="ForewordTitle">FOREWORD</h1>
118
- <div class="boilerplate_legal"/>
119
- </div>
120
- #{IEC_TITLE1}
121
- <div id="_terms_and_definitions"><h1>1&#160; Terms and definitions</h1>
122
- <p class="TermNum" id="paddy1">1.1</p><p class="Terms" style="text-align:left;">paddy</p>
123
-
124
- <p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">&lt;rice&gt; rice retaining its husk after threshing</p>
125
- <div id="_bd57bbf1-f948-4bae-b0ce-73c00431f892" class="example"><p><span class="example_label">EXAMPLE 1</span>&#160; Foreign seeds, husks, bran, sand, dust.</p><ul>
126
- <li>A</li>
127
- </ul></div>
128
- <div id="_bd57bbf1-f948-4bae-b0ce-73c00431f894" class="example"><p><span class="example_label">EXAMPLE 2</span>&#160; </p>
129
- <ul>
130
- <li>A</li>
131
- </ul>
132
- </div>
133
-
134
- <p>[TERMREF]
135
- <a href="#ISO7301">ISO 7301:2011, 3.1</a>
136
- [MODIFICATION]The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here
137
- [/TERMREF]</p><p class="TermNum" id="paddy">1.2</p><p class="Terms" style="text-align:left;">paddy</p><p class="AltTerms" style="text-align:left;">paddy rice</p>
138
- <p class="AltTerms" style="text-align:left;">rough rice</p>
139
- <p class="DeprecatedTerms" style="text-align:left;">DEPRECATED: cargo rice</p>
140
- <p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p>
141
- <div id="_bd57bbf1-f948-4bae-b0ce-73c00431f893" class="example"><p><span class="example_label">EXAMPLE</span>&#160; </p>
142
- <ul>
143
- <li>A</li>
144
- </ul>
145
- </div>
146
- <div id="_671a1994-4783-40d0-bc81-987d06ffb74e" class="Note"><p>Note 1 to entry: The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p></div>
147
- <div id='_671a1994-4783-40d0-bc81-987d06ffb74f' class="Note"><p>Note 2 to entry: <ul><li>A</li></ul><p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p></p></div>
148
- <p>[TERMREF]
149
- <a href="#ISO7301">ISO 7301:2011, 3.1</a>
150
- [/TERMREF]</p></div>
151
- </div>
152
- </body>
153
- </html>
154
- OUTPUT
155
-
115
+ #{HTML_HDR}
116
+ <div id="">
117
+ <h1 class="ForewordTitle">FOREWORD</h1>
118
+ <div class="boilerplate_legal"/>
119
+ </div>
120
+ #{IEC_TITLE1}
121
+ <div id="_terms_and_definitions"><h1>1&#160; Terms and definitions</h1>
122
+ <p class="TermNum" id="paddy1">1.1</p><p class="Terms" style="text-align:left;">paddy</p>
123
+
124
+ <p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">&lt;rice&gt; rice retaining its husk after threshing</p>
125
+ <div id="_bd57bbf1-f948-4bae-b0ce-73c00431f892" class="example"><p><span class="example_label">EXAMPLE 1</span>&#160; Foreign seeds, husks, bran, sand, dust.</p><ul>
126
+ <li>A</li>
127
+ </ul></div>
128
+ <div id="_bd57bbf1-f948-4bae-b0ce-73c00431f894" class="example"><p><span class="example_label">EXAMPLE 2</span>&#160; </p>
129
+ <ul>
130
+ <li>A</li>
131
+ </ul>
132
+ </div>
133
+
134
+ <p>[TERMREF]
135
+ <a href="#ISO7301">ISO 7301:2011, 3.1</a>
136
+ [MODIFICATION]The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here
137
+ [/TERMREF]</p><p class="TermNum" id="paddy">1.2</p><p class="Terms" style="text-align:left;">paddy</p><p class="AltTerms" style="text-align:left;">paddy rice</p>
138
+ <p class="AltTerms" style="text-align:left;">rough rice</p>
139
+ <p class="DeprecatedTerms" style="text-align:left;">DEPRECATED: cargo rice</p>
140
+ <p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p>
141
+ <div id="_bd57bbf1-f948-4bae-b0ce-73c00431f893" class="example"><p><span class="example_label">EXAMPLE</span>&#160; </p>
142
+ <ul>
143
+ <li>A</li>
144
+ </ul>
145
+ </div>
146
+ <div id="_671a1994-4783-40d0-bc81-987d06ffb74e" class="Note"><p>Note 1 to entry: The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p></div>
147
+ <div id='_671a1994-4783-40d0-bc81-987d06ffb74f' class="Note"><p>Note 2 to entry: <ul><li>A</li></ul><p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p></p></div>
148
+ <p>[TERMREF]
149
+ <a href="#ISO7301">ISO 7301:2011, 3.1</a>
150
+ [/TERMREF]</p></div>
151
+ </div>
152
+ </body>
153
+ </html>
154
+ OUTPUT
155
+
156
156
  word = <<~OUTPUT
157
- <div id="_terms_and_definitions"><h1>1<span style="mso-tab-count:1">&#160; </span>Terms and definitions</h1><p class="TermNum" id="paddy1">1.1</p><p class="Terms" style="text-align:left;">paddy</p>
158
-
159
- <p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">&lt;rice&gt; rice retaining its husk after threshing</p>
160
- <div id="_bd57bbf1-f948-4bae-b0ce-73c00431f892" class="example"><p><span class="example_label">EXAMPLE 1</span><span style="mso-tab-count:1">&#160; </span>Foreign seeds, husks, bran, sand, dust.</p><ul>
161
- <li>A</li>
162
- </ul></div>
163
- <div id="_bd57bbf1-f948-4bae-b0ce-73c00431f894" class="example"><p><span class="example_label">EXAMPLE 2</span><span style="mso-tab-count:1">&#160; </span></p>
164
-
165
- <ul>
166
- <li>A</li>
167
- </ul>
168
- </div>
169
-
170
- <p>[TERMREF]
171
- <a href="#ISO7301">ISO 7301:2011, 3.1</a>
172
- [MODIFICATION]The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here
173
- [/TERMREF]</p><p class="TermNum" id="paddy">1.2</p><p class="Terms" style="text-align:left;">paddy</p><p class="AltTerms" style="text-align:left;">paddy rice</p>
174
- <p class="AltTerms" style="text-align:left;">rough rice</p>
175
- <p class="DeprecatedTerms" style="text-align:left;">DEPRECATED: cargo rice</p>
176
- <p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p><div id="_bd57bbf1-f948-4bae-b0ce-73c00431f893" class="example"><p><span class="example_label">EXAMPLE</span><span style="mso-tab-count:1">&#160; </span></p>
177
-
178
- <ul>
179
- <li>A</li>
180
- </ul>
181
- </div><div id="_671a1994-4783-40d0-bc81-987d06ffb74e" class="Note"><p class="Note">Note 1 to entry: The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p></div><div id="_671a1994-4783-40d0-bc81-987d06ffb74f" class="Note"><p class="Note">Note 2 to entry: <ul><li>A</li></ul><p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p></p></div>
182
-
183
-
184
-
185
- <p>[TERMREF]
186
- <a href="#ISO7301">ISO 7301:2011, 3.1</a>
187
- [/TERMREF]</p></div>
188
- OUTPUT
189
- expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({}).convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
190
- expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
191
- expect(xmlpp(IsoDoc::Iec::WordConvert.new({}).convert("test", presxml, true).sub(%r{^.*<div id="_terms_and_definitions">}m, '<div id="_terms_and_definitions">').sub(%r{</div>\s*<br[^>]*>\s*<div class="colophon"/>.*$}m, ""))).to be_equivalent_to xmlpp(word)
157
+ <div id="_terms_and_definitions"><h1>1<span style="mso-tab-count:1">&#160; </span>Terms and definitions</h1><p class="TermNum" id="paddy1">1.1</p><p class="Terms" style="text-align:left;">paddy</p>
158
+
159
+ <p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">&lt;rice&gt; rice retaining its husk after threshing</p>
160
+ <div id="_bd57bbf1-f948-4bae-b0ce-73c00431f892" class="example"><p><span class="example_label">EXAMPLE 1</span><span style="mso-tab-count:1">&#160; </span>Foreign seeds, husks, bran, sand, dust.</p><ul>
161
+ <li>A</li>
162
+ </ul></div>
163
+ <div id="_bd57bbf1-f948-4bae-b0ce-73c00431f894" class="example"><p><span class="example_label">EXAMPLE 2</span><span style="mso-tab-count:1">&#160; </span></p>
164
+
165
+ <ul>
166
+ <li>A</li>
167
+ </ul>
168
+ </div>
169
+
170
+ <p>[TERMREF]
171
+ <a href="#ISO7301">ISO 7301:2011, 3.1</a>
172
+ [MODIFICATION]The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here
173
+ [/TERMREF]</p><p class="TermNum" id="paddy">1.2</p><p class="Terms" style="text-align:left;">paddy</p><p class="AltTerms" style="text-align:left;">paddy rice</p>
174
+ <p class="AltTerms" style="text-align:left;">rough rice</p>
175
+ <p class="DeprecatedTerms" style="text-align:left;">DEPRECATED: cargo rice</p>
176
+ <p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p><div id="_bd57bbf1-f948-4bae-b0ce-73c00431f893" class="example"><p><span class="example_label">EXAMPLE</span><span style="mso-tab-count:1">&#160; </span></p>
177
+
178
+ <ul>
179
+ <li>A</li>
180
+ </ul>
181
+ </div><div id="_671a1994-4783-40d0-bc81-987d06ffb74e" class="Note"><p class="Note">Note 1 to entry: The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p></div><div id="_671a1994-4783-40d0-bc81-987d06ffb74f" class="Note"><p class="Note">Note 2 to entry: <ul><li>A</li></ul><p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p></p></div>
182
+
183
+
184
+
185
+ <p>[TERMREF]
186
+ <a href="#ISO7301">ISO 7301:2011, 3.1</a>
187
+ [/TERMREF]</p></div>
188
+ OUTPUT
189
+ expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({})
190
+ .convert("test", input, true)))
191
+ .to be_equivalent_to xmlpp(presxml)
192
+ expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({})
193
+ .convert("test", presxml, true)))
194
+ .to be_equivalent_to xmlpp(html)
195
+ expect(xmlpp(IsoDoc::Iec::WordConvert.new({})
196
+ .convert("test", presxml, true)
197
+ .sub(%r{^.*<div id="_terms_and_definitions">}m,
198
+ '<div id="_terms_and_definitions">')
199
+ .sub(%r{</div>\s*<br[^>]*>\s*<div class="colophon"/>.*$}m, "")))
200
+ .to be_equivalent_to xmlpp(word)
192
201
  end
193
202
  end
@@ -2,20 +2,112 @@ require "spec_helper"
2
2
  require "metanorma"
3
3
  require "fileutils"
4
4
 
5
- #RSpec.describe Asciidoctor::Gb do
6
5
  RSpec.describe Metanorma::Iec::Processor do
7
-
8
6
  registry = Metanorma::Registry.instance
9
7
  registry.register(Metanorma::Iec::Processor)
10
8
  processor = registry.find_processor(:iec)
11
9
 
10
+ inputxml = <<~INPUT
11
+ <iec-standard xmlns="http://riboseinc.com/isoxml">
12
+ <bibdata type="standard">
13
+ <title language="en" format="text/plain" type="main">English</title>
14
+ <title language="en" format="text/plain" type="title-main">English</title>
15
+ <title language="fr" format="text/plain" type="main">French</title>
16
+ <title language="fr" format="text/plain" type="title-main">French</title>
17
+ <docidentifier type="ISO">ISO DIR 1</docidentifier><docidentifier type="iso-with-lang">ISO DIR 1(F)</docidentifier><docidentifier type="iso-reference">ISO DIR 1(F)</docidentifier>
18
+ <docnumber>1</docnumber>
19
+ <contributor>
20
+ <role type="author"/>
21
+ <organization>
22
+ <name>International Organization for Standardization</name>
23
+ <abbreviation>ISO</abbreviation>
24
+ </organization>
25
+ </contributor>
26
+ <contributor>
27
+ <role type="publisher"/>
28
+ <organization>
29
+ <name>International Organization for Standardization</name>
30
+ <abbreviation>ISO</abbreviation>
31
+ </organization>
32
+ </contributor>
33
+ <language>fr</language>
34
+ <script>Latn</script>
35
+ <status>
36
+ <stage abbreviation="IS">60</stage>
37
+ <substage>60</substage>
38
+ </status>
39
+ <copyright>
40
+ <from>2021</from>
41
+ <owner>
42
+ <organization>
43
+ <name>International Organization for Standardization</name>
44
+ <abbreviation>ISO</abbreviation>
45
+ </organization>
46
+ </owner>
47
+ </copyright>
48
+ <ext>
49
+ <doctype>directive</doctype>
50
+ <subdoctype>vocabulary</subdoctype>
51
+ <editorialgroup>
52
+ <technical-committee/>
53
+ <subcommittee/>
54
+ <workgroup/>
55
+ </editorialgroup>
56
+ <structuredidentifier>
57
+ <project-number>ISO 1</project-number>
58
+ </structuredidentifier>
59
+ <stagename>International standard</stagename>
60
+ </ext>
61
+ </bibdata>
62
+ <boilerplate>
63
+ <copyright-statement>
64
+ <clause>
65
+ <title>DOCUMENT PROT&#201;G&#201; PAR COPYRIGHT</title>
66
+ <p id="boilerplate-year">&#169; ISO 2021</p>
67
+
68
+ <p id="boilerplate-message">
69
+ Droits de reproduction r&#233;serv&#233;s. Sauf indication contraire, aucune partie de cette publication ne
70
+ peut &#234;tre reproduite ni utilis&#233;e sous quelque forme que ce soit et par aucun proc&#233;d&#233;, &#233;lectronique
71
+ ou m&#233;canique, y compris la photocopie, l&#8217;affichage sur l&#8217;internet ou sur un Intranet, sans
72
+ autorisation &#233;crite pr&#233;alable. Les demandes d&#8217;autorisation peuvent &#234;tre adress&#233;es &#224; l&#8217;ISO &#224;
73
+ l&#8217;adresse ci-apr&#232;s ou au comit&#233; membre de l&#8217;ISO dans le pays du demandeur.
74
+ </p>
75
+
76
+ <p id="boilerplate-address" align="left">
77
+ ISO copyright office<br/>
78
+ Ch. de Blandonnet 8 &#8226; CP 401<br/>
79
+ CH-1214 Vernier, Geneva, Switzerland<br/>
80
+ Tel.&#160;&#160;+ 41 22 749 01 11<br/>
81
+ Fax&#160;&#160;+ 41 22 749 09 47<br/>
82
+ Email: copyright@iso.org<br/>
83
+ Website: www.iso.org
84
+ </p>
85
+ <p id="boilerplate-place">
86
+ Publi&#233; en Suisse
87
+ </p>
88
+ </clause>
89
+ </copyright-statement>
90
+
91
+
92
+ </boilerplate>
93
+ <sections>
94
+ <terms id="H" obligation="normative"><title>1&#xA0; Terms, Definitions, Symbols and Abbreviated Terms</title>
95
+ <term id="J">
96
+ <name>1.1</name>
97
+ <preferred>Term2</preferred>
98
+ </term>
99
+ </terms>
100
+ </sections>
101
+ </iec-standard>
102
+ INPUT
103
+
12
104
  it "registers against metanorma" do
13
105
  expect(processor).not_to be nil
14
106
  end
15
107
 
16
108
  it "registers output formats against metanorma" do
17
109
  expect(processor.output_formats.sort.to_s).to be_equivalent_to <<~"OUTPUT"
18
- [[:doc, "doc"], [:html, "html"], [:pdf, "pdf"], [:presentation, "presentation.xml"], [:rxl, "rxl"], [:xml, "xml"]]
110
+ [[:doc, "doc"], [:html, "html"], [:pdf, "pdf"], [:presentation, "presentation.xml"], [:rxl, "rxl"], [:sts, "sts.xml"], [:xml, "xml"]]
19
111
  OUTPUT
20
112
  end
21
113
 
@@ -24,53 +116,56 @@ RSpec.describe Metanorma::Iec::Processor do
24
116
  end
25
117
 
26
118
  it "generates IsoDoc XML from a blank document" do
27
- expect(xmlpp(strip_guid(processor.input_to_isodoc(<<~"INPUT", nil)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
28
- #{ASCIIDOC_BLANK_HDR}
119
+ input = <<~INPUT
120
+ #{ASCIIDOC_BLANK_HDR}
29
121
  INPUT
30
- #{blank_hdr_gen}
31
- <sections/>
32
- </iec-standard>
122
+ output = <<~OUTPUT
123
+ #{blank_hdr_gen}
124
+ <sections/>
125
+ </iec-standard>
33
126
  OUTPUT
127
+ expect(xmlpp(strip_guid(processor.input_to_isodoc(input, nil))))
128
+ .to be_equivalent_to xmlpp(output)
34
129
  end
35
130
 
36
131
  it "generates HTML from IsoDoc XML" do
37
132
  FileUtils.rm_f "test.xml"
38
- processor.output(<<~"INPUT", "test.xml", "test.html", :html)
39
- <iec-standard xmlns="http://riboseinc.com/isoxml">
40
- <sections>
41
- <terms id="H" obligation="normative"><title>1<tab/>Terms, Definitions, Symbols and Abbreviated Terms</title>
42
- <term id="J">
43
- <name>1.1</name>
44
- <preferred>Term2</preferred>
45
- </term>
46
- </terms>
47
- </sections>
48
- </iec-standard>
49
- INPUT
50
- expect(xmlpp(File.read("test.html", encoding: "utf-8").gsub(%r{^.*<main}m, "<main").gsub(%r{</main>.*}m, "</main>"))).to be_equivalent_to xmlpp(<<~"OUTPUT")
51
- <main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
52
- <br />
53
- <p class="zzSTDTitle1">INTERNATIONAL ELECTROTECHNICAL COMMISSION</p>
54
- <p class="zzSTDTitle1">____________</p>
55
- <p class="zzSTDTitle1">&#xA0;</p>
56
- <p class="zzSTDTitle1">
57
- <b></b>
58
- </p>
59
- <p class="zzSTDTitle1">&#xA0;</p>
60
- <div id="">
61
- <h1 class="ForewordTitle" id="toc0">FOREWORD</h1>
62
- <div class="boilerplate_legal"></div>
63
- </div>
64
- <p class="zzSTDTitle1">
65
- <b></b>
66
- </p>
67
- <p class="zzSTDTitle1">&#xA0;</p>
68
- <div id="H"><h1 id="toc1">1&#xA0; Terms, Definitions, Symbols and Abbreviated Terms</h1>
69
- <h2 class="TermNum" id="J">1.1</h2>
70
- <p class="Terms" style="text-align:left;">Term2</p>
71
- </div>
72
- </main>
73
- OUTPUT
133
+ FileUtils.rm_f "test.html"
134
+ processor.output(inputxml, "test.xml", "test.html", :html)
135
+ expect(xmlpp(File.read("test.html", encoding: "utf-8")
136
+ .gsub(%r{^.*<main}m, "<main")
137
+ .gsub(%r{</main>.*}m, "</main>")))
138
+ .to be_equivalent_to xmlpp(<<~"OUTPUT")
139
+ <main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
140
+ <br />
141
+ <p class="zzSTDTitle1">COMMISSION ELECTROTECHNIQUE INTERNATIONALE</p>
142
+ <p class="zzSTDTitle1">____________</p>
143
+ <p class="zzSTDTitle1">&#xA0;</p>
144
+ <p class="zzSTDTitle1">
145
+ <b>French</b>
146
+ </p>
147
+ <p class="zzSTDTitle1">&#xA0;</p>
148
+ <div id="">
149
+ <h1 class="ForewordTitle" id="toc0">AVANT-PROPOS</h1>
150
+ <div class="boilerplate_legal"></div>
151
+ </div>
152
+ <p class="zzSTDTitle1">
153
+ <b>French</b>
154
+ </p>
155
+ <p class="zzSTDTitle1">&#xA0;</p>
156
+ <div id="H"><h1 id="toc1">1&#xA0; Terms, Definitions, Symbols and Abbreviated Terms</h1>
157
+ <h2 class="TermNum" id="J">1.1</h2>
158
+ <p class="Terms" style="text-align:left;">Term2</p>
159
+ </div>
160
+ </main>
161
+ OUTPUT
74
162
  end
75
163
 
164
+ it "generates STS from Metanorma XML" do
165
+ FileUtils.rm_f "test.xml"
166
+ FileUtils.rm_f "test.sts.xml"
167
+ File.open("test.xml", "w") { |f| f.write inputxml }
168
+ processor.output(inputxml, "test.xml", "test.sts.xml", :sts)
169
+ expect(File.exist?("test.sts.xml")).to be true
170
+ end
76
171
  end