metanorma-iso 1.2.4 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/asciidoctor/iso/cleanup.rb +36 -1
- data/lib/asciidoctor/iso/reqt.rng +1 -1
- data/lib/asciidoctor/iso/validate.rb +12 -2
- data/lib/asciidoctor/iso/validate_section.rb +5 -1
- data/lib/asciidoctor/iso/validate_style.rb +16 -1
- data/lib/isodoc/iso/html/html_iso_titlepage.html +3 -5
- data/lib/isodoc/iso/html/style-human.scss +1 -1
- data/lib/isodoc/iso/html/style-iso.scss +1 -1
- data/lib/isodoc/iso/html/wordstyle.scss +4 -0
- data/lib/metanorma/iso/version.rb +1 -1
- data/metanorma-iso.gemspec +2 -2
- data/spec/asciidoctor-iso/cleanup_spec.rb +163 -0
- data/spec/asciidoctor-iso/refs_spec.rb +1 -1
- data/spec/asciidoctor-iso/validate_spec.rb +2 -2
- data/spec/isodoc/i18n_spec.rb +3 -3
- data/spec/isodoc/postproc_spec.rb +4 -4
- data/spec/isodoc/xref_spec.rb +20 -20
- data/spec/spec_helper.rb +1 -1
- metadata +6 -14
- data/docs/adopting-spec.adoc +0 -72
- data/docs/adopting-toolchain.adoc +0 -389
- data/docs/customisation.adoc +0 -7
- data/docs/htmloutput.adoc +0 -118
- data/docs/localizing-output.adoc +0 -57
- data/docs/outputs.adoc +0 -42
- data/docs/replacing-asciidoc.adoc +0 -15
- data/docs/styling-output-msword.adoc +0 -38
@@ -115,7 +115,7 @@ RSpec.describe Asciidoctor::ISO do
|
|
115
115
|
<formattedref format="application/x-isodoc+xml">
|
116
116
|
<em>Standard</em>
|
117
117
|
</formattedref>
|
118
|
-
<docidentifier>[1]</docidentifier>
|
118
|
+
<docidentifier type="metanorma">[1]</docidentifier>
|
119
119
|
</bibitem>
|
120
120
|
</references>
|
121
121
|
</bibliography>
|
@@ -136,7 +136,7 @@ it "warns that definition may contain requirement" do
|
|
136
136
|
end
|
137
137
|
|
138
138
|
it "warns that term example may contain recommendation" do
|
139
|
-
expect { Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true) }.to output(/
|
139
|
+
expect { Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true) }.to output(/Example may contain recommendation/).to_stderr
|
140
140
|
#{VALIDATING_BLANK_HDR}
|
141
141
|
|
142
142
|
== Terms and Definitions
|
@@ -277,7 +277,7 @@ it "warns of Non-ISO reference in Normative References" do
|
|
277
277
|
end
|
278
278
|
|
279
279
|
it "warns that Scope contains subclauses" do
|
280
|
-
expect { Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true) }.to output(%r{Scope contains subclauses: should be
|
280
|
+
expect { Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true) }.to output(%r{Scope contains subclauses: should be succinct}).to_stderr
|
281
281
|
#{VALIDATING_BLANK_HDR}
|
282
282
|
|
283
283
|
== Scope
|
data/spec/isodoc/i18n_spec.rb
CHANGED
@@ -229,7 +229,7 @@ RSpec.describe IsoDoc do
|
|
229
229
|
</bibliography>
|
230
230
|
</iso-standard>
|
231
231
|
INPUT
|
232
|
-
|
232
|
+
#{HTML_HDR.sub(/"en"/, '"tlh"')}
|
233
233
|
<br/>
|
234
234
|
<div>
|
235
235
|
<h1 class="ForewordTitle">Foreword</h1>
|
@@ -386,7 +386,7 @@ RSpec.describe IsoDoc do
|
|
386
386
|
</bibliography>
|
387
387
|
</iso-standard>
|
388
388
|
INPUT
|
389
|
-
|
389
|
+
#{HTML_HDR.sub(/"en"/, '"fr"')}
|
390
390
|
<br/>
|
391
391
|
<div>
|
392
392
|
<h1 class="ForewordTitle">Avant-propos</h1>
|
@@ -553,7 +553,7 @@ RSpec.describe IsoDoc do
|
|
553
553
|
</bibliography>
|
554
554
|
</iso-standard>
|
555
555
|
INPUT
|
556
|
-
|
556
|
+
#{HTML_HDR.sub(/"en"/, '"zh"')}
|
557
557
|
<br/>
|
558
558
|
<div>
|
559
559
|
<h1 class="ForewordTitle">前言</h1>
|
@@ -350,7 +350,7 @@ RSpec.describe IsoDoc do
|
|
350
350
|
<img src="test_htmlimages/_.png" height="776" width="922" />
|
351
351
|
<img src="test_htmlimages/_.png" height="800" width="53" />
|
352
352
|
<img src="test_htmlimages/_.png" height="83" width="99" />
|
353
|
-
<p class="FigureTitle"
|
353
|
+
<p class="FigureTitle" style="text-align:center;">Figure 1 — Split-it-right sample divider</p></div>
|
354
354
|
</div>
|
355
355
|
<p class="zzSTDTitle1"></p>
|
356
356
|
</main>
|
@@ -442,10 +442,10 @@ RSpec.describe IsoDoc do
|
|
442
442
|
</p>
|
443
443
|
<div class="Section3"><a name="P" id="P"></a>
|
444
444
|
<div class="example"><a name="_63112cbc-cde0-435f-9553-e0b8c4f5851c" id="_63112cbc-cde0-435f-9553-e0b8c4f5851c"></a>
|
445
|
-
<p class="
|
445
|
+
<p class="example"><span class="example_label">EXAMPLE 1</span><span style="mso-tab-count:1">  </span>'1M', '01M', and '0001M' all describe the calendar month January.</p>
|
446
446
|
</div>
|
447
447
|
<div class="example"><a name="_63112cbc-cde0-435f-9553-e0b8c4f5851d" id="_63112cbc-cde0-435f-9553-e0b8c4f5851d"></a>
|
448
|
-
<p class="
|
448
|
+
<p class="example"><span class="example_label">EXAMPLE 2</span><span style="mso-tab-count:1">  </span>'2M', '02M', and '0002M' all describe the calendar month February.</p>
|
449
449
|
</div>
|
450
450
|
</div>
|
451
451
|
</div>
|
@@ -485,7 +485,7 @@ RSpec.describe IsoDoc do
|
|
485
485
|
<p class="MsoNormal">Hello</p>
|
486
486
|
<p class="MsoNormal">Key</p>
|
487
487
|
<p class="MsoNormal"><b>Key</b></p><div class="figdl"><table class="figdl"><tr><td valign="top" align="left"><p align="left" style="margin-left:0pt;text-align:left;" class="MsoNormal"><p class="MsoNormal">A</p></p></td><td valign="top"><p class="MsoNormal">B</p></td></tr></table></div>
|
488
|
-
<p class="FigureTitle"
|
488
|
+
<p class="FigureTitle" style="text-align:center;">Figure A.1</p></div>
|
489
489
|
</div>
|
490
490
|
</div>
|
491
491
|
<br clear="all" style="page-break-before:left;mso-break-type:section-break"/>
|
data/spec/isodoc/xref_spec.rb
CHANGED
@@ -191,7 +191,7 @@ RSpec.describe IsoDoc do
|
|
191
191
|
<div id="N" class="figure">
|
192
192
|
|
193
193
|
<img src="rice_images/rice_image1.png" height="auto" width="auto"/>
|
194
|
-
<p class="FigureTitle"
|
194
|
+
<p class="FigureTitle" style="text-align:center;">Figure 1 — Split-it-right sample divider</p></div>
|
195
195
|
<p>
|
196
196
|
<a href="#N">Figure 1</a>
|
197
197
|
</p>
|
@@ -213,11 +213,11 @@ RSpec.describe IsoDoc do
|
|
213
213
|
<div id="note1" class="figure">
|
214
214
|
|
215
215
|
<img src="rice_images/rice_image1.png" height="auto" width="auto"/>
|
216
|
-
<p class="FigureTitle"
|
216
|
+
<p class="FigureTitle" style="text-align:center;">Figure 2 — Split-it-right sample divider</p></div>
|
217
217
|
<div id="note2" class="figure">
|
218
218
|
|
219
219
|
<img src="rice_images/rice_image1.png" height="auto" width="auto"/>
|
220
|
-
<p class="FigureTitle"
|
220
|
+
<p class="FigureTitle" style="text-align:center;">Figure 3 — Split-it-right sample divider</p></div>
|
221
221
|
<p> <a href="#note1">Figure 2</a> <a href="#note2">Figure 3</a> </p>
|
222
222
|
</div>
|
223
223
|
</div>
|
@@ -227,17 +227,17 @@ RSpec.describe IsoDoc do
|
|
227
227
|
<div id="AN" class="figure">
|
228
228
|
|
229
229
|
<img src="rice_images/rice_image1.png" height="auto" width="auto"/>
|
230
|
-
<p class="FigureTitle"
|
230
|
+
<p class="FigureTitle" style="text-align:center;">Figure A.1 — Split-it-right sample divider</p></div>
|
231
231
|
</div>
|
232
232
|
<div id="annex1b"><h2>A.2 </h2>
|
233
233
|
<div id="Anote1" class="figure">
|
234
234
|
|
235
235
|
<img src="rice_images/rice_image1.png" height="auto" width="auto"/>
|
236
|
-
<p class="FigureTitle"
|
236
|
+
<p class="FigureTitle" style="text-align:center;">Figure A.2 — Split-it-right sample divider</p></div>
|
237
237
|
<div id="Anote2" class="figure">
|
238
238
|
|
239
239
|
<img src="rice_images/rice_image1.png" height="auto" width="auto"/>
|
240
|
-
<p class="FigureTitle"
|
240
|
+
<p class="FigureTitle" style="text-align:center;">Figure A.3 — Split-it-right sample divider</p></div>
|
241
241
|
</div>
|
242
242
|
</div>
|
243
243
|
</div>
|
@@ -334,11 +334,11 @@ RSpec.describe IsoDoc do
|
|
334
334
|
<div id="note1" class="figure">
|
335
335
|
|
336
336
|
<img src="rice_images/rice_image1.png" height="auto" width="auto"/>
|
337
|
-
<p class="FigureTitle"
|
337
|
+
<p class="FigureTitle" style="text-align:center;">Figure 1-1 — Split-it-right sample divider</p></div>
|
338
338
|
<div id="note2" class="figure">
|
339
339
|
|
340
340
|
<img src="rice_images/rice_image1.png" height="auto" width="auto"/>
|
341
|
-
<p class="FigureTitle"
|
341
|
+
<p class="FigureTitle" style="text-align:center;">Figure 1-2 — Split-it-right sample divider</p></div>
|
342
342
|
</div>
|
343
343
|
<p> <a href="#note1">Figure 1-1</a> <a href="#note2">Figure 1-2</a> </p>
|
344
344
|
</div>
|
@@ -352,11 +352,11 @@ RSpec.describe IsoDoc do
|
|
352
352
|
<div id="Anote1" class="figure">
|
353
353
|
|
354
354
|
<img src="rice_images/rice_image1.png" height="auto" width="auto"/>
|
355
|
-
<p class="FigureTitle"
|
355
|
+
<p class="FigureTitle" style="text-align:center;">Figure A.1-1 — Split-it-right sample divider</p></div>
|
356
356
|
<div id="Anote2" class="figure">
|
357
357
|
|
358
358
|
<img src="rice_images/rice_image1.png" height="auto" width="auto"/>
|
359
|
-
<p class="FigureTitle"
|
359
|
+
<p class="FigureTitle" style="text-align:center;">Figure A.1-2 — Split-it-right sample divider</p></div>
|
360
360
|
</div>
|
361
361
|
</div>
|
362
362
|
</div>
|
@@ -708,15 +708,15 @@ standardization at the following addresses:</p>
|
|
708
708
|
<p class="zzSTDTitle1"/>
|
709
709
|
<div id="scope">
|
710
710
|
<h1>1  Scope</h1>
|
711
|
-
<p class="TableTitle"
|
711
|
+
<p class="TableTitle" style="text-align:center;">
|
712
712
|
Table 1 — Repeatability and reproducibility of husked rice yield
|
713
713
|
</p>
|
714
|
-
<table id="N" class="MsoISOTable"
|
714
|
+
<table id="N" class="MsoISOTable" style="border-width:1px;border-spacing:0;">
|
715
715
|
<tbody>
|
716
716
|
<tr>
|
717
|
-
<td
|
718
|
-
<td
|
719
|
-
<td
|
717
|
+
<td style="text-align:left;border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;padding:0;">Number of laboratories retained after eliminating outliers</td>
|
718
|
+
<td style="text-align:center;border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;padding:0;">13</td>
|
719
|
+
<td style="text-align:center;border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;padding:0;">11</td>
|
720
720
|
</tr>
|
721
721
|
</tbody>
|
722
722
|
</table>
|
@@ -738,19 +738,19 @@ standardization at the following addresses:</p>
|
|
738
738
|
<div id="widgets">
|
739
739
|
<h1>3  Widgets</h1>
|
740
740
|
<div id="widgets1"><h2>3.1 </h2>
|
741
|
-
<p class="TableTitle"
|
742
|
-
<p class="TableTitle"
|
741
|
+
<p class="TableTitle" style="text-align:center;">Table 2 — Repeatability and reproducibility of husked rice yield</p><table id="note1" class="MsoISOTable" style="border-width:1px;border-spacing:0;"><tbody><tr><td style="text-align:left;border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;padding:0;">Number of laboratories retained after eliminating outliers</td><td style="text-align:center;border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;padding:0;">13</td><td style="text-align:center;border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;padding:0;">11</td></tr></tbody></table>
|
742
|
+
<p class="TableTitle" style="text-align:center;">Table 3 — Repeatability and reproducibility of husked rice yield</p><table id="note2" class="MsoISOTable" style="border-width:1px;border-spacing:0;"><tbody><tr><td style="text-align:left;border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;padding:0;">Number of laboratories retained after eliminating outliers</td><td style="text-align:center;border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;padding:0;">13</td><td style="text-align:center;border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;padding:0;">11</td></tr></tbody></table>
|
743
743
|
<p> <a href="#note1">Table 2</a> <a href="#note2">Table 3</a> </p>
|
744
744
|
</div>
|
745
745
|
</div>
|
746
746
|
<br/>
|
747
747
|
<div id="annex1" class="Section3">
|
748
748
|
<div id="annex1a"><h2>A.1 </h2>
|
749
|
-
<p class="TableTitle"
|
749
|
+
<p class="TableTitle" style="text-align:center;">Table A.1 — Repeatability and reproducibility of husked rice yield</p><table id="AN" class="MsoISOTable" style="border-width:1px;border-spacing:0;"><tbody><tr><td style="text-align:left;border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;padding:0;">Number of laboratories retained after eliminating outliers</td><td style="text-align:center;border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;padding:0;">13</td><td style="text-align:center;border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;padding:0;">11</td></tr></tbody></table>
|
750
750
|
</div>
|
751
751
|
<div id="annex1b"><h2>A.2 </h2>
|
752
|
-
<p class="TableTitle"
|
753
|
-
<p class="TableTitle"
|
752
|
+
<p class="TableTitle" style="text-align:center;">Table A.2 — Repeatability and reproducibility of husked rice yield</p><table id="Anote1" class="MsoISOTable" style="border-width:1px;border-spacing:0;"><tbody><tr><td style="text-align:left;border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;padding:0;">Number of laboratories retained after eliminating outliers</td><td style="text-align:center;border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;padding:0;">13</td><td style="text-align:center;border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;padding:0;">11</td></tr></tbody></table>
|
753
|
+
<p class="TableTitle" style="text-align:center;">Table A.3 — Repeatability and reproducibility of husked rice yield</p><table id="Anote2" class="MsoISOTable" style="border-width:1px;border-spacing:0;"><tbody><tr><td style="text-align:left;border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;padding:0;">Number of laboratories retained after eliminating outliers</td><td style="text-align:center;border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;padding:0;">13</td><td style="text-align:center;border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;padding:0;">11</td></tr></tbody></table>
|
754
754
|
</div>
|
755
755
|
</div>
|
756
756
|
</div>
|
data/spec/spec_helper.rb
CHANGED
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.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -44,28 +44,28 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 1.0.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: 1.0.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: metanorma-standoc
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
61
|
+
version: 1.3.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.
|
68
|
+
version: 1.3.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bundler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -263,18 +263,10 @@ files:
|
|
263
263
|
- appveyor.yml
|
264
264
|
- asciidoctor-iso.gemspec.old
|
265
265
|
- bin/rspec
|
266
|
-
- docs/adopting-spec.adoc
|
267
|
-
- docs/adopting-toolchain.adoc
|
268
266
|
- docs/asciiiso-syntax.adoc
|
269
|
-
- docs/customisation.adoc
|
270
267
|
- docs/guidance.adoc
|
271
|
-
- docs/htmloutput.adoc
|
272
|
-
- docs/localizing-output.adoc
|
273
268
|
- docs/navigation.adoc
|
274
|
-
- docs/outputs.adoc
|
275
269
|
- docs/quickstart.adoc
|
276
|
-
- docs/replacing-asciidoc.adoc
|
277
|
-
- docs/styling-output-msword.adoc
|
278
270
|
- lib/asciidoctor/iso/base.rb
|
279
271
|
- lib/asciidoctor/iso/basicdoc.rng
|
280
272
|
- lib/asciidoctor/iso/biblio.rng
|
data/docs/adopting-spec.adoc
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
= How can I adopt the StanDoc specification for my own publications?
|
2
|
-
|
3
|
-
TIP: Copy the RSD schema from https://github.com/metanorma/metanorma-model-iso/blob/master/grammars/rsd.rng. You may need to adapt some of the enums in the model, or in the ISO Standards model that it inherits; but in the first instance, you can just ignore the differences—and ignore the validation feedback that the toolset gives.
|
4
|
-
|
5
|
-
The Standoc specification is expressed in http://www.relaxng.org[RelaxNG schema for XML], and is intended to be customisable for different types of publication. The customisation of Standoc relies on inheritance, with the following schemas embedded hierarchically:
|
6
|
-
|
7
|
-
* https://github.com/metanorma/relaton-models[Relaton]: bibliography
|
8
|
-
* https://github.com/metanorma/basicdoc-models[BasicDoc]: block-level and inline formatting
|
9
|
-
* https://github.com/metanorma/metanorma-standoc[StanDoc]: organisation of sections for a generic standards document
|
10
|
-
* Models specific to standards
|
11
|
-
|
12
|
-
Specialisation of a model consists of:
|
13
|
-
|
14
|
-
* Adding classes to a base model.
|
15
|
-
* Changing attributes of a base model class. This is not restricted to adding attributes, as is the case in typical entity subclassing; it can also include removing attributes from a class, changing their obligation and cardinality, and changing their type, including changing enumerations. Attributes can be overruled at any level; for example, standards-specific models routinely enhance the bibliographic model at the base of the hierarchy.
|
16
|
-
* For reasons of clarity, renaming classes and attributes is avoided in specialisation.
|
17
|
-
|
18
|
-
To adapt the schema for your publication set,
|
19
|
-
|
20
|
-
* Get familiar with the Standoc set of models, and identify any elements that you would want to represent differently for your documents (different types, different enums), or enhance for your documents (additional element attributes, additional elements)
|
21
|
-
* Create a grammar inheriting from StanDoc or from a specific standard, which expresses what is distinctive about your grammar.
|
22
|
-
** We recommend starting your modelling in UML, as an effective communication tool; compare the UML models for Standoc standards at https://github.com/metanorma/metanorma-model-iso
|
23
|
-
** The tool suite expects to validate against a set of schemas expressed in RelaxNG. We have been authoring grammars in RelaxNG Compact, as a more human-readable format, then compiling those grammars to RelaxNG using https://github.com/relaxng/jing-trang[jing-trang]. You can choose to use a different schema language, but you will need to customise the tool chain to validate against that form of schema instead.
|
24
|
-
** In order to make schema inheritance easier, we have avoided using namespaces for the individual schemas; a namespace is added to the standards-specific schema at the very end of the inheritance chain.
|
25
|
-
|
26
|
-
=== Schema customisation
|
27
|
-
|
28
|
-
For example, the `rsd.rnc` schema, expressed in RelaxNG Compact, is specific to Ribose Standard documents: it inherits from the ISO Standards model, modifying 10 elements, and adding five. As an example of modifying elements, RSD permits preformatted text (Ascii art) in figures, which ISO does not:
|
29
|
-
|
30
|
-
.ISO
|
31
|
-
[source,asciidoctor]
|
32
|
-
----
|
33
|
-
figure =
|
34
|
-
element figure {
|
35
|
-
attribute id { xsd:ID },
|
36
|
-
tname?,
|
37
|
-
( image | subfigure+ ),
|
38
|
-
fn*, dl?, note*
|
39
|
-
}
|
40
|
-
----
|
41
|
-
|
42
|
-
.RSD
|
43
|
-
[source,asciidoctor]
|
44
|
-
----
|
45
|
-
figure =
|
46
|
-
element figure {
|
47
|
-
attribute id { xsd:ID },
|
48
|
-
tname?,
|
49
|
-
( image | pre | subfigure+ ),
|
50
|
-
fn*, dl?, note*
|
51
|
-
}
|
52
|
-
----
|
53
|
-
|
54
|
-
The preformatted text tag `pre` is an addition to the RSD specification, which is why it lies outside the `include "isostandard.rnc {}"` container:
|
55
|
-
|
56
|
-
.RSD
|
57
|
-
[source,asciidoctor]
|
58
|
-
----
|
59
|
-
pre = element pre { text }
|
60
|
-
----
|
61
|
-
|
62
|
-
As another instance of customisation, the `BibItemType` enumeration of permissible bibliographical item types is extended in RSD to include the document types specific to RSD:
|
63
|
-
|
64
|
-
.RSD
|
65
|
-
[source,asciidoctor]
|
66
|
-
----
|
67
|
-
BibItemType |=
|
68
|
-
"policy-and-procedures" | "best-practices" | "supporting-document" | "report" | "legal" | "directives" | "proposal" |
|
69
|
-
"standard"
|
70
|
-
----
|
71
|
-
|
72
|
-
|
@@ -1,389 +0,0 @@
|
|
1
|
-
= How can I adapt the StanDoc toolchain for my own publications?
|
2
|
-
|
3
|
-
[TIP]
|
4
|
-
====
|
5
|
-
The easiest way to adopt StanDoc is to use the metanorma-acme gem: https://github.com/metanorma/metanorma-acme, supplying your own stylesheets and HTML files for styling.
|
6
|
-
|
7
|
-
If you wish to create a custom gem, in order to customise behaviour further:
|
8
|
-
|
9
|
-
* Clone the metanorma-sample gem: https://github.com/metanorma/metanorma-sample.
|
10
|
-
* Change the namespace for RSD documents (`RSD_NAMESPACE = "https://open.ribose.com/standards/rsd"`) to a namespace specific to your organisation's document standard.
|
11
|
-
* Change any references to `sample` or `Sample` in the gem to your organisation's document standard.
|
12
|
-
* Change the styling of the document outputs (`.../lib/isodoc/XXX/html`).
|
13
|
-
====
|
14
|
-
|
15
|
-
The tool chains currently available proceed in two steps: map an input markup language (currently Asciidoctor only) into Standoc XML, and map Standoc XML into various output formats (currently Word doc, HTML, PDF via HTML). Running the metanorma tool involves a third step, of exposing the capabilities available in the first two in a consistent format. These two steps are represented as three separate modules, which are included in the same gem; for the Sample gem, they are `Asciidoctor::Sample`, `Isodoc::Sample`, and `Metanorma::Sample`. (In the case of Metanorma-ISO, almost all the content of `Isodoc::ISO` is in the isodoc gem, so the base classes of the two steps are in separate gems.)
|
16
|
-
|
17
|
-
Your adaptation of the toolchain will need to instantiate these three modules. The connection between the two first steps is taken care of in the toolchain, and metanorma explicitly invokes the two steps, feeding the XML output of the first step as input into the second. The metanorma-sample gem outputs both Word and HTML; you can choose to output only Word (as is done in metanorma-m3d), or only HTML (as is done in metanorma-csand), and you can choose to generate PDF from HTML as well (as is done in metanorma-csd).
|
18
|
-
|
19
|
-
The modules involve classes which rely on inheritance from other classes; the current gems use `Asciidoctor::{Standoc, ISO}::Converter`, `Isodoc::{Metadata, HtmlConvert, WordConvert}`, and `Metanorma::Processor` as their base classes. This allows the standards-specific classes to be quite succinct, as most of their behaviour is inherited from other classes; but it also means that you need to be familiar with the underlying gems, in order to do most customisation.
|
20
|
-
|
21
|
-
In the case of `Asciidoctor::X` classes, the changes you will need to make involve the intermediate XML representation of your document, which is built up through Nokogiri Builder; e.g. adding different enums, or adding new elements. The adaptations in `Asciidoctor::Sample::Converter` are limited, and most projects can take them across as is.
|
22
|
-
|
23
|
-
The customisations needed for `Metanorma::Sample::Processor` are minor, and involve invoking methods specific to the gem for document generation.
|
24
|
-
|
25
|
-
The customisations needed for `Isodoc::Sample` are more extensive. Three base classes are involved:
|
26
|
-
|
27
|
-
* `Isodoc::Metadata` processes the metadata about the document stored in `//bibdata`. This information typically ends up in the document title page, as opposed to the document body. For that reason, metadata is extracted into a hash, which is passed to document output (title page, Word header) via the https://shopify.github.io/liquid/[Liquid template language].
|
28
|
-
* `Isodoc::HtmlConvert` converts Standoc XML to HTML.
|
29
|
-
* `Isodoc::WordConvert` converts Standoc XML to Word HTML; the https://github.com/metanorma/html2doc[html2doc] gem then converts this to a .doc document.
|
30
|
-
|
31
|
-
The `Isodoc::HtmlConvert` and `Isodoc::WordConvert` overlap substantially, as both use variants of HTML. However there is no reason not to make substantially different rendering choices in the HTML and Word branches of the code.
|
32
|
-
|
33
|
-
=== Asciidoctor::Standoc customisation in metanorma-sample
|
34
|
-
|
35
|
-
Examples from `Asciidoctor::Sample` in metanorma-sample. In the following snippets, the parameter `node` represents the current node of the Asciidoctor document, and `xml` represents the Nokogiri Builder node of the XML output.
|
36
|
-
|
37
|
-
* The boilerplate representation of the document's author, publisher and copyright holder names Acme instead of ISO as the responsible organisation.
|
38
|
-
|
39
|
-
[source,ruby]
|
40
|
-
--
|
41
|
-
def metadata_author(node, xml)
|
42
|
-
xml.contributor do |c|
|
43
|
-
c.role **{ type: "author" }
|
44
|
-
c.organization do |a|
|
45
|
-
a.name "Acme"
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
--
|
50
|
-
|
51
|
-
* The editorial committees are represented as a single element, as opposed to ISO's name plus number. (`node.attr()` recovers Asciidoctor document attribute values.)
|
52
|
-
|
53
|
-
[source,ruby]
|
54
|
-
--
|
55
|
-
def metadata_committee(node, xml)
|
56
|
-
xml.editorialgroup do |a|
|
57
|
-
a.committee node.attr("committee"),
|
58
|
-
**attr_code(type: node.attr("committee-type"))
|
59
|
-
end
|
60
|
-
end
|
61
|
-
--
|
62
|
-
|
63
|
-
* The document title is monolingual, not bilingual. (`asciidoc_sub()` is already defined to apply Asciidoctor text substitutions to its contents, such as smart quotes and em-dashes.)
|
64
|
-
|
65
|
-
[source,ruby]
|
66
|
-
--
|
67
|
-
def title(node, xml)
|
68
|
-
["en"].each do |lang|
|
69
|
-
xml.title **{ language: lang, format: "plain" } do |t|
|
70
|
-
t << asciidoc_sub(node.attr("title"))
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
--
|
75
|
-
|
76
|
-
* The document status is a single element, as opposed to ISO's two-part code.
|
77
|
-
|
78
|
-
[source,ruby]
|
79
|
-
--
|
80
|
-
def metadata_status(node, xml)
|
81
|
-
xml.status(**{ format: "plain" }) { |s| s << node.attr("status") }
|
82
|
-
end
|
83
|
-
--
|
84
|
-
|
85
|
-
* The document identifier is a single element.
|
86
|
-
|
87
|
-
[source,ruby]
|
88
|
-
--
|
89
|
-
def metadata_id(node, xml)
|
90
|
-
xml.docidentifier { |i| i << node.attr("docnumber") }
|
91
|
-
end
|
92
|
-
--
|
93
|
-
|
94
|
-
* A security element is added to the document metadata.
|
95
|
-
|
96
|
-
[source,ruby]
|
97
|
-
--
|
98
|
-
def metadata_security(node, xml)
|
99
|
-
security = node.attr("security") || return
|
100
|
-
xml.security security
|
101
|
-
end
|
102
|
-
|
103
|
-
def metadata(node, xml)
|
104
|
-
super
|
105
|
-
metadata_security(node, xml)
|
106
|
-
end
|
107
|
-
--
|
108
|
-
|
109
|
-
* Title validation and style validation is disabled.
|
110
|
-
|
111
|
-
[source,ruby]
|
112
|
-
--
|
113
|
-
def title_validate(root)
|
114
|
-
nil
|
115
|
-
end
|
116
|
-
--
|
117
|
-
|
118
|
-
* The root element of the document is changed from `iso-standard` to `sample-standard`.
|
119
|
-
|
120
|
-
[source,ruby]
|
121
|
-
--
|
122
|
-
def makexml(node)
|
123
|
-
result = ["<?xml version='1.0' encoding='UTF-8'?>\n<sample-standard>"]
|
124
|
-
@draft = node.attributes.has_key?("draft")
|
125
|
-
result << noko { |ixml| front node, ixml }
|
126
|
-
result << noko { |ixml| middle node, ixml }
|
127
|
-
result << "</sample-standard>"
|
128
|
-
....
|
129
|
-
end
|
130
|
-
--
|
131
|
-
|
132
|
-
* The document type attribute is restricted to a prescribed set of options.
|
133
|
-
|
134
|
-
[source,ruby]
|
135
|
-
--
|
136
|
-
def doctype(node)
|
137
|
-
d = node.attr("doctype")
|
138
|
-
unless %w{policy-and-procedures best-practices
|
139
|
-
supporting-document report legal directives proposal
|
140
|
-
standard}.include? d
|
141
|
-
warn "#{d} is not a legal document type: reverting to 'standard'"
|
142
|
-
d = "standard"
|
143
|
-
end
|
144
|
-
d
|
145
|
-
end
|
146
|
-
--
|
147
|
-
|
148
|
-
* The `literal` asciidoctor block is processed as a preformatted tag (`pre`).
|
149
|
-
(The code uses the built-in Asciidoctor `literal()` method, and embeds `pre` within a `figure` tag.)
|
150
|
-
|
151
|
-
[source,ruby]
|
152
|
-
--
|
153
|
-
def literal(node)
|
154
|
-
noko do |xml|
|
155
|
-
xml.figure **id_attr(node) do |f|
|
156
|
-
figure_title(node, f)
|
157
|
-
f.pre node.lines.join("\n")
|
158
|
-
end
|
159
|
-
end
|
160
|
-
end
|
161
|
-
--
|
162
|
-
|
163
|
-
* A `keyword` element is added. (The keyword is encoded through the role attribute of Asciidoc: `[.keyword]#text#`)
|
164
|
-
|
165
|
-
[source,ruby]
|
166
|
-
--
|
167
|
-
def inline_quoted(node)
|
168
|
-
noko do |xml|
|
169
|
-
case node.type
|
170
|
-
...
|
171
|
-
else
|
172
|
-
case node.role
|
173
|
-
...
|
174
|
-
when "keyword" then xml.keyword node.text
|
175
|
-
else
|
176
|
-
xml << node.text
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end.join
|
180
|
-
end
|
181
|
-
--
|
182
|
-
|
183
|
-
* The inline headers of ISO are ignored.
|
184
|
-
|
185
|
-
[source,ruby]
|
186
|
-
--
|
187
|
-
def sections_cleanup(x)
|
188
|
-
super
|
189
|
-
x.xpath("//*[@inline-header]").each do |h|
|
190
|
-
h.delete("inline-header")
|
191
|
-
end
|
192
|
-
end
|
193
|
-
--
|
194
|
-
|
195
|
-
=== Metanorma::Processor customisation in metanorma-sample
|
196
|
-
|
197
|
-
* `initialize` names the token by which Asciidoctor registers the standard
|
198
|
-
|
199
|
-
[source,ruby]
|
200
|
-
--
|
201
|
-
def initialize
|
202
|
-
@short = :sample
|
203
|
-
@input_format = :asciidoc
|
204
|
-
@asciidoctor_backend = :sample
|
205
|
-
end
|
206
|
-
--
|
207
|
-
|
208
|
-
* `output_formats` names the available output formats (including XML, which is inherited from the parent class)
|
209
|
-
|
210
|
-
[source,ruby]
|
211
|
-
--
|
212
|
-
def output_formats
|
213
|
-
super.merge(
|
214
|
-
html: "html",
|
215
|
-
doc: "doc",
|
216
|
-
pdf: "pdf"
|
217
|
-
)
|
218
|
-
end
|
219
|
-
--
|
220
|
-
|
221
|
-
* `version` gives the current version string for the gem
|
222
|
-
|
223
|
-
[source,ruby]
|
224
|
-
--
|
225
|
-
def version
|
226
|
-
"Asciidoctor::Sample #{Asciidoctor::Sample::VERSION}"
|
227
|
-
end
|
228
|
-
--
|
229
|
-
|
230
|
-
* `input_to_isodoc` is the call which converts Asciidoctor input into IsoDoc XML
|
231
|
-
|
232
|
-
[source,ruby]
|
233
|
-
--
|
234
|
-
def input_to_isodoc(file, filename)
|
235
|
-
Metanorma::Input::Asciidoc.new.process(file, filename, @asciidoctor_backend)
|
236
|
-
end
|
237
|
-
--
|
238
|
-
|
239
|
-
* `output` is the call which converts IsoDoc XML into various nominated output formats
|
240
|
-
|
241
|
-
[source,ruby]
|
242
|
-
--
|
243
|
-
def output(isodoc_node, outname, format, options={})
|
244
|
-
case format
|
245
|
-
when :html
|
246
|
-
IsoDoc::Sample::HtmlConvert.new(options).convert(outname, isodoc_node)
|
247
|
-
when :doc
|
248
|
-
IsoDoc::Sample::WordConvert.new(options).convert(outname, isodoc_node)
|
249
|
-
when :pdf
|
250
|
-
IsoDoc::Sample::PdfConvert.new(options).convert(outname, isodoc_node)
|
251
|
-
else
|
252
|
-
super
|
253
|
-
end
|
254
|
-
end
|
255
|
-
--
|
256
|
-
|
257
|
-
=== Isodoc::Standoc customisation in metanorma-sample
|
258
|
-
|
259
|
-
* Initialise the HTML Converter:
|
260
|
-
** Set `@libdir`, the current directory of the HTML converter, and the basis of the `html_doc_path()` method for accessing HTML assets (the `html` subdirectory of the current directory).
|
261
|
-
** Copy the logo JPG from the HTML asset directory to the working directory, so that it can be access by the HTML template; flag the copy for deletion at the end of processing.
|
262
|
-
|
263
|
-
[source,ruby]
|
264
|
-
--
|
265
|
-
def initialize(options)
|
266
|
-
@libdir = File.dirname(__FILE__)
|
267
|
-
super
|
268
|
-
FileUtils.cp html_doc_path('logo.jpg'), "logo.jpg"
|
269
|
-
@files_to_delete << "logo.jpg"
|
270
|
-
end
|
271
|
-
--
|
272
|
-
|
273
|
-
* Set the default fonts for the HTML rendering, which will be used to populate the HTML CSS stylesheet.
|
274
|
-
|
275
|
-
[source,ruby]
|
276
|
-
--
|
277
|
-
class HtmlConvert < IsoDoc::HtmlConvert
|
278
|
-
def default_fonts(options)
|
279
|
-
{
|
280
|
-
bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' : '"Overpass",sans-serif'),
|
281
|
-
headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' : '"Overpass",sans-serif'),
|
282
|
-
monospacefont: '"Space Mono",monospace'
|
283
|
-
}
|
284
|
-
end
|
285
|
-
--
|
286
|
-
|
287
|
-
* Set the default HTML assets for the HTML rendering.
|
288
|
-
|
289
|
-
[source,ruby]
|
290
|
-
--
|
291
|
-
class HtmlConvert < IsoDoc::HtmlConvert
|
292
|
-
def default_file_locations(_options)
|
293
|
-
{
|
294
|
-
htmlstylesheet: html_doc_path("htmlstyle.scss"),
|
295
|
-
htmlcoverpage: html_doc_path("html_sample_titlepage.html"),
|
296
|
-
htmlintropage: html_doc_path("html_sample_intro.html"),
|
297
|
-
scripts: html_doc_path("scripts.html"),
|
298
|
-
}
|
299
|
-
end
|
300
|
-
--
|
301
|
-
|
302
|
-
* Set distinct default fonts and HTML assets for the Word rendering.
|
303
|
-
|
304
|
-
[source,ruby]
|
305
|
-
--
|
306
|
-
class WordConvert < IsoDoc::WordConvert
|
307
|
-
def default_fonts(options)
|
308
|
-
{
|
309
|
-
bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' : '"Arial",sans-serif'),
|
310
|
-
headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' : '"Arial",sans-serif'),
|
311
|
-
monospacefont: '"Courier New",monospace'
|
312
|
-
}
|
313
|
-
end
|
314
|
-
|
315
|
-
def default_file_locations(_options)
|
316
|
-
{
|
317
|
-
wordstylesheet: html_doc_path("wordstyle.scss"),
|
318
|
-
standardstylesheet: html_doc_path("sample.scss"),
|
319
|
-
header: html_doc_path("header.html"),
|
320
|
-
wordcoverpage: html_doc_path("word_sample_titlepage.html"),
|
321
|
-
wordintropage: html_doc_path("word_sample_intro.html"),
|
322
|
-
ulstyle: "l3",
|
323
|
-
olstyle: "l2",
|
324
|
-
}
|
325
|
-
end
|
326
|
-
--
|
327
|
-
|
328
|
-
|
329
|
-
* Set the content of the HTML head, other than the CSS stylesheets. Note that the head title is given as a Liquid Template reference to metadata ()`{{ doctitle }}`, which we have seen populated above.)
|
330
|
-
|
331
|
-
[source,ruby]
|
332
|
-
--
|
333
|
-
def html_head
|
334
|
-
<<~HEAD.freeze
|
335
|
-
<title>{{ doctitle }}</title>
|
336
|
-
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
337
|
-
<!--TOC script import-->
|
338
|
-
<script type="text/javascript" src="https://cdn.rawgit.com/jgallen23/toc/0.3.2/dist/toc.min.js"></script>
|
339
|
-
<!--Google fonts-->
|
340
|
-
....
|
341
|
-
<style class="anchorjs"></style>
|
342
|
-
HEAD
|
343
|
-
end
|
344
|
-
--
|
345
|
-
|
346
|
-
* Change the default label for annexes from "Annex" to "Appendix".
|
347
|
-
|
348
|
-
[source,ruby]
|
349
|
-
--
|
350
|
-
def i18n_init(lang, script)
|
351
|
-
super
|
352
|
-
@annex_lbl = "Appendix"
|
353
|
-
end
|
354
|
-
--
|
355
|
-
|
356
|
-
* Define rendering for the `pre` and `keyword` preformatted text tags.
|
357
|
-
|
358
|
-
[source,ruby]
|
359
|
-
--
|
360
|
-
def pre_parse(node, out)
|
361
|
-
out.pre node.text # content.gsub(/</, "<").gsub(/>/, ">")
|
362
|
-
end
|
363
|
-
|
364
|
-
def error_parse(node, out)
|
365
|
-
# catch elements not defined in ISO
|
366
|
-
case node.name
|
367
|
-
when "pre"
|
368
|
-
pre_parse(node, out)
|
369
|
-
when "keyword"
|
370
|
-
out.span node.text, **{ class: "keyword" }
|
371
|
-
else
|
372
|
-
super
|
373
|
-
end
|
374
|
-
end
|
375
|
-
--
|
376
|
-
|
377
|
-
* Render term headings in the same paragraph as the term heading number
|
378
|
-
|
379
|
-
[source,ruby]
|
380
|
-
--
|
381
|
-
def term_cleanup(docxml)
|
382
|
-
docxml.xpath("//p[@class = 'Terms']").each do |d|
|
383
|
-
h2 = d.at("./preceding-sibling::*[@class = 'TermNum'][1]")
|
384
|
-
h2.add_child(" ")
|
385
|
-
h2.add_child(d.remove)
|
386
|
-
end
|
387
|
-
docxml
|
388
|
-
end
|
389
|
-
--
|