metanorma-standoc 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/.gitattributes +4 -0
  3. data/.gitignore +11 -0
  4. data/.hound.yml +3 -0
  5. data/.oss-guides.rubocop.yml +1077 -0
  6. data/.rubocop.ribose.yml +66 -0
  7. data/.rubocop.tb.yml +650 -0
  8. data/.rubocop.yml +15 -0
  9. data/.travis.yml +21 -0
  10. data/CODE_OF_CONDUCT.md +46 -0
  11. data/Gemfile +7 -0
  12. data/LICENSE +25 -0
  13. data/Makefile +39 -0
  14. data/README.adoc +9 -0
  15. data/Rakefile +6 -0
  16. data/bin/rspec +18 -0
  17. data/docs/customisation.adoc +178 -0
  18. data/docs/guidance.adoc +436 -0
  19. data/docs/htmloutput.adoc +115 -0
  20. data/docs/quickstart.adoc +375 -0
  21. data/lib/asciidoctor/standoc/base.rb +198 -0
  22. data/lib/asciidoctor/standoc/biblio.rng +836 -0
  23. data/lib/asciidoctor/standoc/blocks.rb +190 -0
  24. data/lib/asciidoctor/standoc/cleanup.rb +247 -0
  25. data/lib/asciidoctor/standoc/cleanup_block.rb +193 -0
  26. data/lib/asciidoctor/standoc/cleanup_footnotes.rb +78 -0
  27. data/lib/asciidoctor/standoc/cleanup_ref.rb +125 -0
  28. data/lib/asciidoctor/standoc/converter.rb +55 -0
  29. data/lib/asciidoctor/standoc/front.rb +121 -0
  30. data/lib/asciidoctor/standoc/inline.rb +134 -0
  31. data/lib/asciidoctor/standoc/isodoc.rng +1059 -0
  32. data/lib/asciidoctor/standoc/lists.rb +87 -0
  33. data/lib/asciidoctor/standoc/macros.rb +95 -0
  34. data/lib/asciidoctor/standoc/ref.rb +187 -0
  35. data/lib/asciidoctor/standoc/section.rb +159 -0
  36. data/lib/asciidoctor/standoc/table.rb +61 -0
  37. data/lib/asciidoctor/standoc/utils.rb +121 -0
  38. data/lib/asciidoctor/standoc/validate.rb +65 -0
  39. data/lib/asciidoctor/standoc/validate_section.rb +42 -0
  40. data/lib/asciidoctor/standoc/version.rb +5 -0
  41. data/lib/metanorma-standoc.rb +9 -0
  42. data/lib/metanorma/standoc.rb +7 -0
  43. data/lib/metanorma/standoc/processor.rb +40 -0
  44. data/metanorma-standoc.gemspec +47 -0
  45. data/spec/asciidoctor-standoc/base_spec.rb +271 -0
  46. data/spec/asciidoctor-standoc/blocks_spec.rb +469 -0
  47. data/spec/asciidoctor-standoc/cleanup_spec.rb +760 -0
  48. data/spec/asciidoctor-standoc/inline_spec.rb +162 -0
  49. data/spec/asciidoctor-standoc/isobib_cache_spec.rb +332 -0
  50. data/spec/asciidoctor-standoc/lists_spec.rb +190 -0
  51. data/spec/asciidoctor-standoc/macros_spec.rb +111 -0
  52. data/spec/asciidoctor-standoc/refs_spec.rb +606 -0
  53. data/spec/asciidoctor-standoc/section_spec.rb +310 -0
  54. data/spec/asciidoctor-standoc/table_spec.rb +307 -0
  55. data/spec/asciidoctor-standoc/validate_spec.rb +133 -0
  56. data/spec/assets/header.html +7 -0
  57. data/spec/assets/html.css +2 -0
  58. data/spec/assets/htmlcover.html +4 -0
  59. data/spec/assets/htmlintro.html +5 -0
  60. data/spec/assets/i18n.yaml +2 -0
  61. data/spec/assets/iso.headless.html +33 -0
  62. data/spec/assets/iso.xml +8 -0
  63. data/spec/assets/rice_image1.png +0 -0
  64. data/spec/assets/scripts.html +3 -0
  65. data/spec/assets/std.css +2 -0
  66. data/spec/assets/word.css +2 -0
  67. data/spec/assets/wordcover.html +3 -0
  68. data/spec/assets/wordintro.html +4 -0
  69. data/spec/examples/103_01_02.html +247 -0
  70. data/spec/examples/english.yaml +69 -0
  71. data/spec/examples/iso_123_.xml +45 -0
  72. data/spec/examples/iso_123_all_parts.xml +45 -0
  73. data/spec/examples/iso_123_no_year_note.xml +46 -0
  74. data/spec/examples/iso_124_.xml +41 -0
  75. data/spec/examples/iso_216_.xml +47 -0
  76. data/spec/examples/iso_iec_12382_.xml +48 -0
  77. data/spec/examples/rice.adoc +715 -0
  78. data/spec/examples/rice.preview.html +1877 -0
  79. data/spec/examples/rice.sh +4 -0
  80. data/spec/examples/rice_images/rice_image1.png +0 -0
  81. data/spec/examples/rice_images/rice_image2.png +0 -0
  82. data/spec/examples/rice_images/rice_image3_1.png +0 -0
  83. data/spec/examples/rice_images/rice_image3_2.png +0 -0
  84. data/spec/examples/rice_images/rice_image3_3.png +0 -0
  85. data/spec/metanorma/processor_spec.rb +70 -0
  86. data/spec/spec_helper.rb +198 -0
  87. metadata +370 -0
@@ -0,0 +1,190 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Asciidoctor::Standoc do
4
+ it "processes simple lists" do
5
+ output = Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
6
+ #{ASCIIDOC_BLANK_HDR}
7
+ * List 1
8
+ * List 2
9
+ * List 3
10
+
11
+ . List A
12
+ . List B
13
+ . List C
14
+
15
+ List D:: List E
16
+ List F:: List G
17
+
18
+ INPUT
19
+ expect(strip_guid(output)).to be_equivalent_to <<~"OUTPUT"
20
+ #{BLANK_HDR}
21
+ <sections>
22
+ <ul id="_">
23
+ <li>
24
+ <p id="_">List 1</p>
25
+ </li>
26
+ <li>
27
+ <p id="_">List 2</p>
28
+ </li>
29
+ <li>
30
+ <p id="_">List 3</p>
31
+ <ol id="_" type="arabic">
32
+ <li>
33
+ <p id="_">List A</p>
34
+ </li>
35
+ <li>
36
+ <p id="_">List B</p>
37
+ </li>
38
+ <li>
39
+ <p id="_">List C</p>
40
+ <dl id="_">
41
+ <dt>List D</dt>
42
+ <dd>
43
+ <p id="_">List E</p>
44
+ </dd>
45
+ <dt>List F</dt>
46
+ <dd>
47
+ <p id="_">List G</p>
48
+ </dd>
49
+ </dl>
50
+ </li>
51
+ </ol>
52
+ </li>
53
+ </ul>
54
+ </sections>
55
+ </standard-document>
56
+ OUTPUT
57
+ end
58
+
59
+ it "processes complex lists" do
60
+ output = Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
61
+ #{ASCIIDOC_BLANK_HDR}
62
+ [[id]]
63
+ * First
64
+ * Second
65
+ +
66
+ --
67
+ entry1
68
+
69
+ entry2
70
+ --
71
+
72
+ [[id1]]
73
+ [loweralpha]
74
+ . First
75
+ . Second
76
+ [upperalpha]
77
+ .. Third
78
+ .. Fourth
79
+ . Fifth
80
+ . Sixth
81
+
82
+ [lowerroman]
83
+ . A
84
+ . B
85
+ [upperroman]
86
+ .. C
87
+ .. D
88
+ [arabic]
89
+ ... E
90
+ ... F
91
+
92
+
93
+ Notes1::
94
+ Notes:: Note 1.
95
+ +
96
+ Note 2.
97
+ +
98
+ Note 3.
99
+
100
+ INPUT
101
+ expect(strip_guid(output)).to be_equivalent_to <<~"OUTPUT"
102
+ #{BLANK_HDR}
103
+ <sections><ul id="id">
104
+ <li>
105
+ <p id="_">First</p>
106
+ </li>
107
+ <li><p id="_">Second</p><p id="_">entry1</p>
108
+ <p id="_">entry2</p></li>
109
+ </ul>
110
+ <ol id="id1" type="alphabet">
111
+ <li>
112
+ <p id="_">First</p>
113
+ </li>
114
+ <li>
115
+ <p id="_">Second</p>
116
+ <ol id="_" type="alphabet_upper">
117
+ <li>
118
+ <p id="_">Third</p>
119
+ </li>
120
+ <li>
121
+ <p id="_">Fourth</p>
122
+ </li>
123
+ </ol>
124
+ </li>
125
+ <li>
126
+ <p id="_">Fifth</p>
127
+ </li>
128
+ <li>
129
+ <p id="_">Sixth</p>
130
+ </li>
131
+ </ol>
132
+ <ol id="_" type="roman">
133
+ <li>
134
+ <p id="_">A</p>
135
+ </li>
136
+ <li>
137
+ <p id="_">B</p>
138
+ <ol id="_" type="roman_upper">
139
+ <li>
140
+ <p id="_">C</p>
141
+ </li>
142
+ <li>
143
+ <p id="_">D</p>
144
+ <ol id="_" type="arabic">
145
+ <li>
146
+ <p id="_">E</p>
147
+ </li>
148
+ <li>
149
+ <p id="_">F</p>
150
+ <dl id="_">
151
+ <dt>Notes1</dt>
152
+ <dd/>
153
+ <dt>Notes</dt>
154
+ <dd><p id="_">Note 1.</p><p id="_">Note 2.</p>
155
+ <p id="_">Note 3.</p></dd>
156
+ </dl>
157
+ </li>
158
+ </ol>
159
+ </li>
160
+ </ol>
161
+ </li>
162
+ </ol></sections>
163
+ </standard-document>
164
+ OUTPUT
165
+ end
166
+
167
+ it "anchors lists and list items" do
168
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
169
+ #{ASCIIDOC_BLANK_HDR}
170
+ [[id1]]
171
+ * [[id2]] List item
172
+ * Hello [[id3]] List item
173
+
174
+ INPUT
175
+ #{BLANK_HDR}
176
+ <sections>
177
+ <ul id="id1">
178
+ <li id="id2">
179
+ <p id="_">List item</p>
180
+ </li>
181
+ <li>
182
+ <p id="_">Hello <bookmark id="id3"/> List item</p>
183
+ </li>
184
+ </ul>
185
+ </sections>
186
+ </standard-document>
187
+ OUTPUT
188
+ end
189
+
190
+ end
@@ -0,0 +1,111 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Asciidoctor::Standoc do
4
+ it "processes the Asciidoctor::Standoc inline macros" do
5
+ expect(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)).to be_equivalent_to <<~"OUTPUT"
6
+ #{ASCIIDOC_BLANK_HDR}
7
+ alt:[term1]
8
+ deprecated:[term1]
9
+ domain:[term1]
10
+ INPUT
11
+ #{BLANK_HDR}
12
+ <sections>
13
+ <admitted>term1</admitted>
14
+ <deprecates>term1</deprecates>
15
+ <domain>term1</domain>
16
+ </sections>
17
+ </standard-document>
18
+ OUTPUT
19
+ end
20
+
21
+ it "processes the PlantUML macro" do
22
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
23
+ #{ASCIIDOC_BLANK_HDR}
24
+
25
+ [plantuml]
26
+ ....
27
+ @startuml
28
+ Alice -> Bob: Authentication Request
29
+ Bob --> Alice: Authentication Response
30
+
31
+ Alice -> Bob: Another authentication Request
32
+ Alice <-- Bob: another authentication Response
33
+ @enduml
34
+ ....
35
+
36
+ [plantuml]
37
+ ....
38
+ Alice -> Bob: Authentication Request
39
+ Bob --> Alice: Authentication Response
40
+
41
+ Alice -> Bob: Another authentication Request
42
+ Alice <-- Bob: another authentication Response
43
+ ....
44
+ INPUT
45
+ #{BLANK_HDR}
46
+ <sections><figure id="_">
47
+ <image src="plantuml/20.png" id="_" imagetype="PNG" height="auto" width="auto"/>
48
+ </figure>
49
+ <figure id="_">
50
+ <image src="plantuml/29.png" id="_" imagetype="PNG" height="auto" width="auto"/>
51
+ </figure></sections>
52
+
53
+ </standard-document>
54
+ OUTPUT
55
+ end
56
+
57
+ it "processes the PlantUML macro with PlantUML disabled" do
58
+ mock_plantuml_disabled
59
+ expect { Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true) }.to output(%r{PlantUML not installed}).to_stderr
60
+ #{ASCIIDOC_BLANK_HDR}
61
+
62
+ [plantuml]
63
+ ....
64
+ @startuml
65
+ Alice -> Bob: Authentication Request
66
+ Bob --> Alice: Authentication Response
67
+
68
+ Alice -> Bob: Another authentication Request
69
+ Alice <-- Bob: another authentication Response
70
+ @enduml
71
+ ....
72
+ INPUT
73
+
74
+ mock_plantuml_disabled
75
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
76
+ #{ASCIIDOC_BLANK_HDR}
77
+
78
+ [plantuml]
79
+ ....
80
+ @startuml
81
+ Alice -> Bob: Authentication Request
82
+ Bob --> Alice: Authentication Response
83
+
84
+ Alice -> Bob: Another authentication Request
85
+ Alice <-- Bob: another authentication Response
86
+ @enduml
87
+ ....
88
+ INPUT
89
+ #{BLANK_HDR}
90
+ <sections>
91
+ <sourcecode id="_">@startuml
92
+ Alice -&gt; Bob: Authentication Request
93
+ Bob --&gt; Alice: Authentication Response
94
+
95
+ Alice -&gt; Bob: Another authentication Request
96
+ Alice &lt;-- Bob: another authentication Response
97
+ @enduml</sourcecode>
98
+ </sourcecode>
99
+ </standard-document>
100
+ OUTPUT
101
+ end
102
+
103
+
104
+ private
105
+
106
+ def mock_plantuml_disabled
107
+ expect(Asciidoctor::Standoc::PlantUMLBlockMacroBackend).to receive(:plantuml_installed?) do
108
+ false
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,606 @@
1
+ require "spec_helper"
2
+ require "isobib"
3
+
4
+ RSpec.describe Asciidoctor::Standoc do
5
+ it "processes simple ISO reference" do
6
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
7
+ #{ASCIIDOC_BLANK_HDR}
8
+ [bibliography]
9
+ == Normative References
10
+
11
+ * [[[iso123,ISO 123]]] _Standard_
12
+ INPUT
13
+ #{BLANK_HDR}
14
+ <sections>
15
+ </sections><bibliography><references id="_" obligation="informative">
16
+ <title>Normative References</title>
17
+ <bibitem id="iso123" type="standard">
18
+ <title format="text/plain">Standard</title>
19
+ <docidentifier>ISO 123</docidentifier>
20
+ <contributor>
21
+ <role type="publisher"/>
22
+ <organization>
23
+ <name>ISO</name>
24
+ </organization>
25
+ </contributor>
26
+ </bibitem>
27
+ </references>
28
+ </bibliography>
29
+ </standard-document>
30
+ OUTPUT
31
+ end
32
+
33
+ it "processes simple ISO reference with date range" do
34
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
35
+ #{ASCIIDOC_BLANK_HDR}
36
+ [bibliography]
37
+ == Normative References
38
+
39
+ * [[[iso123,ISO 123:1066-1067]]] _Standard_
40
+ INPUT
41
+ #{BLANK_HDR}
42
+ <sections>
43
+ </sections><bibliography><references id="_" obligation="informative">
44
+ <title>Normative References</title>
45
+ <bibitem id="iso123" type="standard">
46
+ <title format="text/plain">Standard</title>
47
+ <docidentifier>ISO 123</docidentifier>
48
+ <date type="published">
49
+ <from>1066</from>
50
+ <to>1067</to>
51
+ </date>
52
+ <contributor>
53
+ <role type="publisher"/>
54
+ <organization>
55
+ <name>ISO</name>
56
+ </organization>
57
+ </contributor>
58
+ </bibitem>
59
+ </references>
60
+ </bibliography>
61
+ </standard-document>
62
+ OUTPUT
63
+ end
64
+
65
+
66
+ it "fetches simple ISO reference" do
67
+ mock_isobib_get_123
68
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
69
+ #{ISOBIB_BLANK_HDR}
70
+ [bibliography]
71
+ == Normative References
72
+
73
+ * [[[iso123,ISO 123]]] _Standard_
74
+ INPUT
75
+ #{BLANK_HDR}
76
+ <sections>
77
+ </sections><bibliography><references id="_" obligation="informative">
78
+ <title>Normative References</title>
79
+ <bibitem type="international-standard" id="iso123">
80
+ <title format="text/plain" language="en" script="Latn">Rubber latex -- Sampling</title>
81
+ <title format="text/plain" language="fr" script="Latn">Latex de caoutchouc -- ?chantillonnage</title>
82
+ <uri type="src">https://www.iso.org/standard/23281.html</uri>
83
+ <uri type="obp">https://www.iso.org/obp/ui/#!iso:std:23281:en</uri>
84
+ <uri type="rss">https://www.iso.org/contents/data/standard/02/32/23281.detail.rss</uri>
85
+ <docidentifier>ISO 123</docidentifier>
86
+ <date type="published">
87
+ <on>2001</on>
88
+ </date>
89
+ <contributor>
90
+ <role type="publisher"/>
91
+ <organization>
92
+ <name>International Organization for Standardization</name>
93
+ <abbreviation>ISO</abbreviation>
94
+ <uri>www.iso.org</uri>
95
+ </organization>
96
+ </contributor>
97
+ <edition>3</edition>
98
+ <language>en</language>
99
+ <language>fr</language>
100
+ <script>Latn</script>
101
+ <status>Published</status>
102
+ <copyright>
103
+ <from>2001</from>
104
+ <owner>
105
+ <organization>
106
+ <name>ISO</name>
107
+ <abbreviation/>
108
+ </organization>
109
+ </owner>
110
+ </copyright>
111
+ <relation type="obsoletes">
112
+ <bibitem>
113
+ <formattedref>ISO 123:1985</formattedref>
114
+ </bibitem>
115
+ </relation>
116
+ <relation type="updates">
117
+ <bibitem>
118
+ <formattedref>ISO 123:2001</formattedref>
119
+ </bibitem>
120
+ </relation>
121
+ </bibitem>
122
+ </references></bibliography>
123
+ </standard-document>
124
+ OUTPUT
125
+ end
126
+
127
+ it "processes simple IEC reference" do
128
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
129
+ #{ASCIIDOC_BLANK_HDR}
130
+ [bibliography]
131
+ == Normative References
132
+
133
+ * [[[iso123,IEC 123]]] _Standard_
134
+ INPUT
135
+ #{BLANK_HDR}
136
+ <sections>
137
+ </sections><bibliography><references id="_" obligation="informative">
138
+ <title>Normative References</title>
139
+ <bibitem id="iso123" type="standard">
140
+ <title format="text/plain">Standard</title>
141
+ <docidentifier>IEC 123</docidentifier>
142
+ <contributor>
143
+ <role type="publisher"/>
144
+ <organization>
145
+ <name>IEC</name>
146
+ </organization>
147
+ </contributor>
148
+ </bibitem>
149
+ </references>
150
+ </bibliography>
151
+ </standard-document>
152
+ OUTPUT
153
+ end
154
+
155
+ it "processes dated ISO reference and joint ISO/IEC references" do
156
+ mock_isobib_get_iec12382
157
+ mock_isobib_get_124
158
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
159
+ #{ISOBIB_BLANK_HDR}
160
+ [bibliography]
161
+ == Normative References
162
+
163
+ * [[[iso123,ISO/IEC TR 12382:1992]]] _Standard_
164
+ * [[[iso124,ISO 124:2014]]] _Standard_
165
+ INPUT
166
+ #{BLANK_HDR}
167
+ <sections>
168
+
169
+ </sections><bibliography><references id="_" obligation="informative">
170
+ <title>Normative References</title>
171
+ <bibitem type="international-standard" id="iso123">
172
+ <title format="text/plain" language="en" script="Latn">Permuted index of the vocabulary of information technology</title>
173
+ <title format="text/plain" language="fr" script="Latn">Index permuté du vocabulaire des technologies de l'information</title>
174
+ <uri type="src">https://www.iso.org/standard/21071.html</uri>
175
+ <uri type="obp">https://www.iso.org/obp/ui/#!iso:std:21071:en</uri>
176
+ <uri type="rss">https://www.iso.org/contents/data/standard/02/10/21071.detail.rss</uri>
177
+ <docidentifier>ISO/IEC 12382</docidentifier>
178
+ <date type="published">
179
+ <on>1992</on>
180
+ </date>
181
+ <contributor>
182
+ <role type="publisher"/>
183
+ <organization>
184
+ <name>International Organization for Standardization</name>
185
+ <abbreviation>ISO</abbreviation>
186
+ <uri>www.iso.org</uri>
187
+ </organization>
188
+ </contributor>
189
+ <contributor>
190
+ <role type="publisher"/>
191
+ <organization>
192
+ <name>International Electrotechnical Commission</name>
193
+ <abbreviation>IEC</abbreviation>
194
+ <uri>www.iec.ch</uri>
195
+ </organization>
196
+ </contributor>
197
+ <edition>2</edition>
198
+ <language>en</language>
199
+ <language>fr</language>
200
+ <script>Latn</script>
201
+ <abstract format="plain" language="en" script="Latn">Contains a permuted index of all terms included in the parts 1 - 28 of ISO 2382. If any of these parts has been revised, the present TR refers to the revision.</abstract>
202
+ <status>Published</status>
203
+ <copyright>
204
+ <from>1992</from>
205
+ <owner>
206
+ <organization>
207
+ <name>ISO/IEC</name>
208
+ <abbreviation/>
209
+ </organization>
210
+ </owner>
211
+ </copyright>
212
+ <relation type="updates">
213
+ <bibitem>
214
+ <formattedref>ISO/IEC TR 12382:1992</formattedref>
215
+ </bibitem>
216
+ </relation>
217
+ <ics>
218
+ <code>35.020</code>
219
+ <text>Information technology (IT) in general</text>
220
+ </ics>
221
+ <ics>
222
+ <code>01.040.35</code>
223
+ <text>Information technology (Vocabularies)</text>
224
+ </ics>
225
+ </bibitem>
226
+ <bibitem type="international-standard" id="iso124">
227
+ <title format="text/plain" language="en" script="Latn">Latex, rubber -- Determination of total solids content</title>
228
+ <title format="text/plain" language="fr" script="Latn">Latex de caoutchouc -- Détermination des matières solides totales</title>
229
+ <uri type="src">https://www.iso.org/standard/61884.html</uri>
230
+ <uri type="obp">https://www.iso.org/obp/ui/#!iso:std:61884:en</uri>
231
+ <uri type="rss">https://www.iso.org/contents/data/standard/06/18/61884.detail.rss</uri>
232
+ <docidentifier>ISO 124</docidentifier>
233
+ <date type="published">
234
+ <on>2014</on>
235
+ </date>
236
+ <contributor>
237
+ <role type="publisher"/>
238
+ <organization>
239
+ <name>International Organization for Standardization</name>
240
+ <abbreviation>ISO</abbreviation>
241
+ <uri>www.iso.org</uri>
242
+ </organization>
243
+ </contributor>
244
+ <edition>7</edition>
245
+ <language>en</language>
246
+ <language>fr</language>
247
+ <script>Latn</script>
248
+ <abstract format="plain" language="en" script="Latn">ISO 124:2014 specifies methods for the determination of the total solids content of natural rubber field and concentrated latices and synthetic rubber latex. These methods are not necessarily suitable for latex from natural sources other than the Hevea brasiliensis, for vulcanized latex, for compounded latex, or for artificial dispersions of rubber.</abstract>
249
+ <status>Published</status>
250
+ <copyright>
251
+ <from>2014</from>
252
+ <owner>
253
+ <organization>
254
+ <name>ISO</name>
255
+ <abbreviation/>
256
+ </organization>
257
+ </owner>
258
+ </copyright>
259
+ <relation type="obsoletes">
260
+ <bibitem>
261
+ <formattedref>ISO 124:2011</formattedref>
262
+ </bibitem>
263
+ </relation>
264
+ <ics>
265
+ <code>83.040.10</code>
266
+ <text>Latex and raw rubber</text>
267
+ </ics>
268
+ </bibitem>
269
+ </references></bibliography>
270
+ </standard-document>
271
+
272
+ OUTPUT
273
+ end
274
+
275
+ it "processes draft ISO reference" do
276
+ #stub_fetch_ref no_year: true, note: "The standard is in press"
277
+
278
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
279
+ #{ASCIIDOC_BLANK_HDR}
280
+ [bibliography]
281
+ == Normative References
282
+
283
+ * [[[iso123,ISO 123:--]]] footnote:[The standard is in press] _Standard_
284
+ INPUT
285
+ #{BLANK_HDR}
286
+ <sections>
287
+ </sections><bibliography><references id="_" obligation="informative">
288
+ <title>Normative References</title>
289
+ <bibitem id="iso123" type="standard">
290
+ <title format="text/plain">Standard</title>
291
+ <docidentifier>ISO 123</docidentifier>
292
+ <date type="published">
293
+ <on>--</on>
294
+ </date>
295
+ <contributor>
296
+ <role type="publisher"/>
297
+ <organization>
298
+ <name>ISO</name>
299
+ </organization>
300
+ </contributor>
301
+ <note format="text/plain">ISO DATE: The standard is in press</note>
302
+ </bibitem>
303
+ </references>
304
+ </bibliography>
305
+ </standard-document>
306
+ OUTPUT
307
+ end
308
+
309
+ it "processes all-parts ISO reference" do
310
+ #stub_fetch_ref(all_parts: true)
311
+
312
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
313
+ #{ASCIIDOC_BLANK_HDR}
314
+ [bibliography]
315
+ == Normative References
316
+
317
+ * [[[iso123,ISO 123:1066 (all parts)]]] _Standard_
318
+ INPUT
319
+ #{BLANK_HDR}
320
+ <sections>
321
+ </sections><bibliography><references id="_" obligation="informative">
322
+ <title>Normative References</title>
323
+ <bibitem id="iso123" type="standard">
324
+ <title format="text/plain">Standard</title>
325
+ <docidentifier>ISO 123</docidentifier>
326
+ <date type="published">
327
+ <on>1066</on>
328
+ </date>
329
+ <contributor>
330
+ <role type="publisher"/>
331
+ <organization>
332
+ <name>ISO</name>
333
+ </organization>
334
+ </contributor>
335
+ <allParts>true</allParts>
336
+ </bibitem>
337
+ </references>
338
+ </bibliography>
339
+ </standard-document>
340
+ OUTPUT
341
+ end
342
+
343
+ it "processes RFC reference in Normative References" do
344
+ mock_rfcbib_get_rfc8341
345
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
346
+ #{ISOBIB_BLANK_HDR}
347
+ [bibliography]
348
+ == Normative References
349
+
350
+ * [[[iso123,IETF RFC 8341]]] _Standard_
351
+ INPUT
352
+ #{BLANK_HDR}
353
+ <sections>
354
+
355
+ </sections><bibliography><references id="_" obligation="informative">
356
+ <title>Normative References</title>
357
+ <bibitem type="" id="iso123">
358
+ <title format="text/plain" language="en" script="Latn">Network Configuration Access Control Model</title>
359
+ <docidentifier>8341</docidentifier>
360
+ <date type="published">
361
+ <on>2018</on>
362
+ </date>
363
+ <status>published</status>
364
+ </bibitem>
365
+ </references>
366
+ </bibliography>
367
+ </standard-document>
368
+ OUTPUT
369
+ end
370
+
371
+ it "processes non-ISO reference in Normative References" do
372
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
373
+ #{ASCIIDOC_BLANK_HDR}
374
+ [bibliography]
375
+ == Normative References
376
+
377
+ * [[[iso123,XYZ 123:1066 (all parts)]]] _Standard_
378
+ INPUT
379
+ #{BLANK_HDR}
380
+ <sections>
381
+
382
+ </sections><bibliography><references id="_" obligation="informative">
383
+ <title>Normative References</title>
384
+ <bibitem id="iso123">
385
+ <formattedref format="application/x-isodoc+xml">
386
+ <em>Standard</em>
387
+ </formattedref>
388
+ <docidentifier>XYZ 123:1066 (all parts)</docidentifier>
389
+ </bibitem>
390
+ </references>
391
+ </bibliography>
392
+ </standard-document>
393
+ OUTPUT
394
+ end
395
+
396
+ it "processes non-ISO reference in Bibliography" do
397
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
398
+ #{ASCIIDOC_BLANK_HDR}
399
+ [bibliography]
400
+ == Bibliography
401
+
402
+ * [[[iso123,1]]] _Standard_
403
+ INPUT
404
+ #{BLANK_HDR}
405
+ <sections>
406
+
407
+ </sections><bibliography><references id="_" obligation="informative">
408
+ <title>Bibliography</title>
409
+ <bibitem id="iso123">
410
+ <formattedref format="application/x-isodoc+xml">
411
+ <em>Standard</em>
412
+ </formattedref>
413
+ <docidentifier>[1]</docidentifier>
414
+ </bibitem>
415
+ </references>
416
+ </bibliography>
417
+ </standard-document>
418
+ OUTPUT
419
+ end
420
+
421
+ it "process ISO reference without an Internet connection" do
422
+ expect(Isobib::IsoBibliography).to receive(:search).with("ISO 123") do
423
+ raise Algolia::AlgoliaProtocolError.new "getaddrinfo", "nodename nor servname provided, or not known (JCL49WV5AR-dsn.algolia.net:443)"
424
+ end.at_least :once
425
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
426
+ #{ISOBIB_BLANK_HDR}
427
+ [bibliography]
428
+ == Normative References
429
+
430
+ * [[[iso123,ISO 123]]] _Standard_
431
+ INPUT
432
+ <?xml version="1.0" encoding="UTF-8"?>
433
+ <standard-document xmlns="http://riboseinc.com/isoxml">
434
+ <bibdata type="article">
435
+ <docidentifier>
436
+ <project-number> </project-number>
437
+ </docidentifier>
438
+ <language>en</language>
439
+ <script>Latn</script>
440
+ <status format="plain">published</status>
441
+ <copyright>
442
+ <from>2018</from>
443
+ </copyright>
444
+ <editorialgroup>
445
+ <technical-committee/>
446
+ </editorialgroup>
447
+ </bibdata>
448
+ <sections>
449
+
450
+ </sections><bibliography><references id="_" obligation="informative">
451
+ <title>Normative References</title>
452
+ <bibitem id="iso123" type="standard">
453
+ <title format="text/plain">Standard</title>
454
+ <docidentifier>ISO 123</docidentifier>
455
+ <contributor>
456
+ <role type="publisher"/>
457
+ <organization>
458
+ <name>ISO</name>
459
+ </organization>
460
+ </contributor>
461
+ </bibitem>
462
+ </references></bibliography>
463
+ </standard-document>
464
+ OUTPUT
465
+ end
466
+
467
+ private
468
+
469
+ private
470
+
471
+ def mock_isobib_get_123
472
+ expect(Isobib::IsoBibliography).to receive(:get).with("ISO 123", nil, {}) do
473
+ IsoBibItem.from_xml(<<~"OUTPUT")
474
+ <bibitem type=\"international-standard\" id=\"ISO123\">\n <title format=\"text/plain\" language=\"en\" script=\"Latn\">Rubber latex -- Sampling</title>\n <title format=\"text/plain\" language=\"fr\" script=\"Latn\">Latex de caoutchouc -- ?chantillonnage</title>\n <uri type=\"src\">https://www.iso.org/standard/23281.html</uri>\n <uri type=\"obp\">https://www.iso.org/obp/ui/#!iso:std:23281:en</uri>\n <uri type=\"rss\">https://www.iso.org/contents/data/standard/02/32/23281.detail.rss</uri>\n <docidentifier>ISO 123</docidentifier>\n <date type=\"published\">\n <on>2001</on>\n </date>\n <contributor>\n <role type=\"publisher\"/>\n <organization>\n <name>International Organization for Standardization</name>\n <abbreviation>ISO</abbreviation>\n <uri>www.iso.org</uri>\n </organization>\n </contributor>\n <edition>3</edition>\n <language>en</language>\n <language>fr</language>\n <script>Latn</script>\n <status>Published</status>\n <copyright>\n <from>2001</from>\n <owner>\n <organization>\n <name>ISO</name>\n <abbreviation></abbreviation>\n </organization>\n </owner>\n </copyright>\n <relation type=\"obsoletes\">\n <bibitem>\n <formattedref>ISO 123:1985</formattedref>\n </bibitem>\n </relation>\n <relation type=\"updates\">\n <bibitem>\n <formattedref>ISO 123:2001</formattedref>\n </bibitem>\n </relation>\n</bibitem>
475
+ OUTPUT
476
+ end
477
+ end
478
+
479
+ def mock_isobib_get_124
480
+ expect(Isobib::IsoBibliography).to receive(:get).with("ISO 124", "2014", {}) do
481
+ IsoBibItem.from_xml(<<~"OUTPUT")
482
+ <bibitem type="international-standard" id="iso124">
483
+ <title format="text/plain" language="en" script="Latn">Latex, rubber -- Determination of total solids content</title>
484
+ <title format="text/plain" language="fr" script="Latn">Latex de caoutchouc -- Détermination des matières solides totales</title>
485
+ <uri type="src">https://www.iso.org/standard/61884.html</uri>
486
+ <uri type="obp">https://www.iso.org/obp/ui/#!iso:std:61884:en</uri>
487
+ <uri type="rss">https://www.iso.org/contents/data/standard/06/18/61884.detail.rss</uri>
488
+ <docidentifier>ISO 124</docidentifier>
489
+ <date type="published">
490
+ <on>2014</on>
491
+ </date>
492
+ <contributor>
493
+ <role type="publisher"/>
494
+ <organization>
495
+ <name>International Organization for Standardization</name>
496
+ <abbreviation>ISO</abbreviation>
497
+ <uri>www.iso.org</uri>
498
+ </organization>
499
+ </contributor>
500
+ <edition>7</edition>
501
+ <language>en</language>
502
+ <language>fr</language>
503
+ <script>Latn</script>
504
+ <abstract format="plain" language="en" script="Latn">ISO 124:2014 specifies methods for the determination of the total solids content of natural rubber field and concentrated latices and synthetic rubber latex. These methods are not necessarily suitable for latex from natural sources other than the Hevea brasiliensis, for vulcanized latex, for compounded latex, or for artificial dispersions of rubber.</abstract>
505
+ <status>Published</status>
506
+ <copyright>
507
+ <from>2014</from>
508
+ <owner>
509
+ <organization>
510
+ <name>ISO</name>
511
+ <abbreviation/>
512
+ </organization>
513
+ </owner>
514
+ </copyright>
515
+ <relation type="obsoletes">
516
+ <bibitem>
517
+ <formattedref>ISO 124:2011</formattedref>
518
+ </bibitem>
519
+ </relation>
520
+ <ics>
521
+ <code>83.040.10</code>
522
+ <text>Latex and raw rubber</text>
523
+ </ics>
524
+ </bibitem>
525
+ OUTPUT
526
+ end
527
+ end
528
+
529
+ def mock_isobib_get_iec12382
530
+ expect(Isobib::IsoBibliography).to receive(:get).with("ISO/IEC TR 12382", "1992", {}) do
531
+ IsoBibItem.from_xml(<<~"OUTPUT")
532
+ <bibitem type="international-standard" id="iso123">
533
+ <title format="text/plain" language="en" script="Latn">Permuted index of the vocabulary of information technology</title>
534
+ <title format="text/plain" language="fr" script="Latn">Index permuté du vocabulaire des technologies de l'information</title>
535
+ <uri type="src">https://www.iso.org/standard/21071.html</uri>
536
+ <uri type="obp">https://www.iso.org/obp/ui/#!iso:std:21071:en</uri>
537
+ <uri type="rss">https://www.iso.org/contents/data/standard/02/10/21071.detail.rss</uri>
538
+ <docidentifier>ISO/IEC 12382</docidentifier>
539
+ <date type="published">
540
+ <on>1992</on>
541
+ </date>
542
+ <contributor>
543
+ <role type="publisher"/>
544
+ <organization>
545
+ <name>International Organization for Standardization</name>
546
+ <abbreviation>ISO</abbreviation>
547
+ <uri>www.iso.org</uri>
548
+ </organization>
549
+ </contributor>
550
+ <contributor>
551
+ <role type="publisher"/>
552
+ <organization>
553
+ <name>International Electrotechnical Commission</name>
554
+ <abbreviation>IEC</abbreviation>
555
+ <uri>www.iec.ch</uri>
556
+ </organization>
557
+ </contributor>
558
+ <edition>2</edition>
559
+ <language>en</language>
560
+ <language>fr</language>
561
+ <script>Latn</script>
562
+ <abstract format="plain" language="en" script="Latn">Contains a permuted index of all terms included in the parts 1 - 28 of ISO 2382. If any of these parts has been revised, the present TR refers to the revision.</abstract>
563
+ <status>Published</status>
564
+ <copyright>
565
+ <from>1992</from>
566
+ <owner>
567
+ <organization>
568
+ <name>ISO/IEC</name>
569
+ <abbreviation/>
570
+ </organization>
571
+ </owner>
572
+ </copyright>
573
+ <relation type="updates">
574
+ <bibitem>
575
+ <formattedref>ISO/IEC TR 12382:1992</formattedref>
576
+ </bibitem>
577
+ </relation>
578
+ <ics>
579
+ <code>35.020</code>
580
+ <text>Information technology (IT) in general</text>
581
+ </ics>
582
+ <ics>
583
+ <code>01.040.35</code>
584
+ <text>Information technology (Vocabularies)</text>
585
+ </ics>
586
+ </bibitem>
587
+ OUTPUT
588
+ end
589
+ end
590
+
591
+ def mock_rfcbib_get_rfc8341
592
+ expect(RfcBib::RfcBibliography).to receive(:get).with("RFC 8341", nil, {}) do
593
+ IsoBibItem.from_xml(<<~"OUTPUT")
594
+ <bibitem id="RFC8341">
595
+ <title format="text/plain" language="en" script="Latn">Network Configuration Access Control Model</title>
596
+ <docidentifier>8341</docidentifier>
597
+ <date type="published">
598
+ <on>2018</on>
599
+ </date>
600
+ <status>published</status>
601
+ </bibitem>
602
+ OUTPUT
603
+ end
604
+ end
605
+
606
+ end