asciidoctor-iso 0.0.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +2 -0
  3. data/.gitignore +1 -0
  4. data/.hound.yml +3 -0
  5. data/.rubocop.ribose.yml +65 -0
  6. data/.rubocop.tb.yml +640 -0
  7. data/Gemfile +4 -0
  8. data/Gemfile.lock +162 -0
  9. data/Makefile +39 -0
  10. data/README.adoc +396 -59
  11. data/Rakefile +6 -0
  12. data/asciidoctor-iso.gemspec +11 -3
  13. data/lib/asciidoctor/iso/base.rb +122 -51
  14. data/lib/asciidoctor/iso/blocks.rb +119 -108
  15. data/lib/asciidoctor/iso/cleanup.rb +214 -0
  16. data/lib/asciidoctor/iso/cleanup_block.rb +157 -0
  17. data/lib/asciidoctor/iso/converter.rb +5 -3
  18. data/lib/asciidoctor/iso/front.rb +37 -28
  19. data/lib/asciidoctor/iso/html/header.html +184 -0
  20. data/lib/asciidoctor/iso/html/html_iso_intro.html +73 -0
  21. data/lib/asciidoctor/iso/html/html_iso_titlepage.html +31 -0
  22. data/lib/asciidoctor/iso/html/htmlstyle.css +67 -0
  23. data/lib/asciidoctor/iso/html/isodoc.css +679 -0
  24. data/lib/asciidoctor/iso/html/word_iso_intro.html +72 -0
  25. data/lib/asciidoctor/iso/html/word_iso_titlepage.html +58 -0
  26. data/lib/asciidoctor/iso/inline_anchor.rb +20 -26
  27. data/lib/asciidoctor/iso/isostandard.rnc +177 -0
  28. data/lib/asciidoctor/iso/isostandard.rng +1478 -0
  29. data/lib/asciidoctor/iso/isostandard_diff.rnc +295 -0
  30. data/lib/asciidoctor/iso/lists.rb +152 -109
  31. data/lib/asciidoctor/iso/section.rb +164 -0
  32. data/lib/asciidoctor/iso/table.rb +30 -27
  33. data/lib/asciidoctor/iso/utils.rb +61 -183
  34. data/lib/asciidoctor/iso/validate.make.sh +8 -0
  35. data/lib/asciidoctor/iso/validate.rb +195 -24
  36. data/lib/asciidoctor/iso/validate_style.rb +175 -0
  37. data/lib/asciidoctor/iso/version.rb +1 -1
  38. data/spec/examples/rice.adoc +45 -24
  39. data/spec/examples/rice.doc +17708 -0
  40. data/spec/examples/rice.html +1574 -1662
  41. data/spec/examples/rice.preview.html +1811 -0
  42. data/spec/examples/rice.sh +4 -0
  43. data/spec/examples/rice.xml +888 -62
  44. data/spec/examples/rice_images/rice_image1.png +0 -0
  45. data/spec/examples/rice_images/rice_image2.png +0 -0
  46. data/spec/examples/rice_images/rice_image3_1.png +0 -0
  47. data/spec/examples/rice_images/rice_image3_2.png +0 -0
  48. data/spec/examples/rice_images/rice_image3_3.png +0 -0
  49. metadata +135 -12
  50. data/grammar1.gif +0 -0
  51. data/grammar2.gif +0 -0
  52. data/grammar3.gif +0 -0
  53. data/grammar4.gif +0 -0
  54. data/lib/asciidoctor/iso/validate.rnc +0 -444
  55. data/lib/asciidoctor/iso/validate.rng +0 -1001
data/Gemfile CHANGED
@@ -1,4 +1,8 @@
1
1
  source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in ribose.gemspec
4
+ gem "html2doc",
5
+ git: "https://github.com/riboseinc/html2doc.git"
6
+ gem "isodoc",
7
+ git: "https://github.com/riboseinc/isodoc.git"
4
8
  gemspec
@@ -0,0 +1,162 @@
1
+ GIT
2
+ remote: https://github.com/riboseinc/html2doc.git
3
+ revision: 1b65fde5d80501506554276174cda5d438f122f5
4
+ specs:
5
+ html2doc (0.0.1)
6
+ asciimath
7
+ htmlentities (~> 4.3.4)
8
+ image_size
9
+ mime-types
10
+ nokogiri (~> 1.8.1)
11
+ ruby-xslt
12
+ thread_safe
13
+ uuidtools
14
+
15
+ GIT
16
+ remote: https://github.com/riboseinc/isodoc.git
17
+ revision: 45ea6e5fd3e3f1416c294a2e460f69fee268e0d2
18
+ specs:
19
+ isodoc (0.0.1)
20
+ asciimath
21
+ html2doc
22
+ htmlentities (~> 4.3.4)
23
+ image_size
24
+ mime-types
25
+ nokogiri (= 1.8.1)
26
+ ruby-xslt
27
+ thread_safe
28
+ uuidtools
29
+
30
+ PATH
31
+ remote: .
32
+ specs:
33
+ asciidoctor-iso (0.0.1)
34
+ asciidoctor (~> 1.5.6)
35
+ asciimath
36
+ html2doc
37
+ htmlentities (~> 4.3.4)
38
+ image_size
39
+ mime-types
40
+ nokogiri (= 1.8.1)
41
+ ruby-jing
42
+ ruby-xslt
43
+ thread_safe
44
+ uuidtools
45
+
46
+ GEM
47
+ remote: https://rubygems.org/
48
+ specs:
49
+ asciidoctor (1.5.6.1)
50
+ asciimath (1.0.4)
51
+ ast (2.4.0)
52
+ byebug (9.1.0)
53
+ coderay (1.1.2)
54
+ diff-lcs (1.3)
55
+ docile (1.1.5)
56
+ equivalent-xml (0.6.0)
57
+ nokogiri (>= 1.4.3)
58
+ ffi (1.9.18)
59
+ formatador (0.2.5)
60
+ guard (2.14.2)
61
+ formatador (>= 0.2.4)
62
+ listen (>= 2.7, < 4.0)
63
+ lumberjack (>= 1.0.12, < 2.0)
64
+ nenv (~> 0.1)
65
+ notiffany (~> 0.0)
66
+ pry (>= 0.9.12)
67
+ shellany (~> 0.0)
68
+ thor (>= 0.18.1)
69
+ guard-compat (1.2.1)
70
+ guard-rspec (4.7.3)
71
+ guard (~> 2.1)
72
+ guard-compat (~> 1.1)
73
+ rspec (>= 2.99.0, < 4.0)
74
+ htmlentities (4.3.4)
75
+ image_size (1.5.0)
76
+ json (2.1.0)
77
+ listen (3.1.5)
78
+ rb-fsevent (~> 0.9, >= 0.9.4)
79
+ rb-inotify (~> 0.9, >= 0.9.7)
80
+ ruby_dep (~> 1.2)
81
+ lumberjack (1.0.12)
82
+ method_source (0.9.0)
83
+ mime-types (3.1)
84
+ mime-types-data (~> 3.2015)
85
+ mime-types-data (3.2016.0521)
86
+ mini_portile2 (2.3.0)
87
+ nenv (0.3.0)
88
+ nokogiri (1.8.1)
89
+ mini_portile2 (~> 2.3.0)
90
+ notiffany (0.1.1)
91
+ nenv (~> 0.1)
92
+ shellany (~> 0.0)
93
+ optout (0.0.2)
94
+ parallel (1.12.1)
95
+ parser (2.4.0.2)
96
+ ast (~> 2.3)
97
+ powerpack (0.1.1)
98
+ pry (0.11.3)
99
+ coderay (~> 1.1.0)
100
+ method_source (~> 0.9.0)
101
+ rainbow (3.0.0)
102
+ rake (12.3.0)
103
+ rb-fsevent (0.10.2)
104
+ rb-inotify (0.9.10)
105
+ ffi (>= 0.5.0, < 2)
106
+ rspec (3.7.0)
107
+ rspec-core (~> 3.7.0)
108
+ rspec-expectations (~> 3.7.0)
109
+ rspec-mocks (~> 3.7.0)
110
+ rspec-core (3.7.1)
111
+ rspec-support (~> 3.7.0)
112
+ rspec-expectations (3.7.0)
113
+ diff-lcs (>= 1.2.0, < 2.0)
114
+ rspec-support (~> 3.7.0)
115
+ rspec-mocks (3.7.0)
116
+ diff-lcs (>= 1.2.0, < 2.0)
117
+ rspec-support (~> 3.7.0)
118
+ rspec-support (3.7.1)
119
+ rubocop (0.52.1)
120
+ parallel (~> 1.10)
121
+ parser (>= 2.4.0.2, < 3.0)
122
+ powerpack (~> 0.1)
123
+ rainbow (>= 2.2.2, < 4.0)
124
+ ruby-progressbar (~> 1.7)
125
+ unicode-display_width (~> 1.0, >= 1.0.1)
126
+ ruby-jing (0.0.1)
127
+ optout (>= 0.0.2)
128
+ ruby-progressbar (1.9.0)
129
+ ruby-xslt (0.9.10)
130
+ ruby_dep (1.5.0)
131
+ shellany (0.0.1)
132
+ simplecov (0.15.1)
133
+ docile (~> 1.1.0)
134
+ json (>= 1.8, < 3)
135
+ simplecov-html (~> 0.10.0)
136
+ simplecov-html (0.10.2)
137
+ thor (0.20.0)
138
+ thread_safe (0.3.6)
139
+ timecop (0.9.1)
140
+ unicode-display_width (1.3.0)
141
+ uuidtools (2.1.5)
142
+
143
+ PLATFORMS
144
+ ruby
145
+
146
+ DEPENDENCIES
147
+ asciidoctor-iso!
148
+ bundler (~> 1.15)
149
+ byebug (~> 9.1)
150
+ equivalent-xml (~> 0.6)
151
+ guard (~> 2.14)
152
+ guard-rspec (~> 4.7)
153
+ html2doc!
154
+ isodoc!
155
+ rake (~> 12.0)
156
+ rspec (~> 3.6)
157
+ rubocop (~> 0.50)
158
+ simplecov (~> 0.15)
159
+ timecop (~> 0.9)
160
+
161
+ BUNDLED WITH
162
+ 1.16.1
@@ -0,0 +1,39 @@
1
+ SRC := $(wildcard draft-*.adoc)
2
+ TXT := $(patsubst %.adoc,%.txt,$(SRC))
3
+ XML := $(patsubst %.adoc,%.xml,$(SRC))
4
+ HTML := $(patsubst %.adoc,%.html,$(SRC))
5
+ NITS := $(patsubst %.adoc,%.nits,$(SRC))
6
+
7
+ SHELL := /bin/bash
8
+ # Ensure the xml2rfc cache directory exists locally
9
+ IGNORE := $(shell mkdir -p $(HOME)/.cache/xml2rfc)
10
+
11
+ all: $(TXT) $(HTML) $(XML) $(NITS)
12
+
13
+ clean:
14
+ rm -f $(TXT) $(HTML) $(XML)
15
+
16
+ %.xml: %.adoc
17
+ #bundle exec asciidoctor -r ./lib/glob-include-processor.rb -r asciidoctor-rfc -b rfc2 $^ --trace > $@
18
+ bundle exec asciidoctor -r ./lib/glob-include-processor.rb -r asciidoctor-rfc -b rfc2 -a flush-biblio=true $^ --trace > $@
19
+
20
+ %.xml3: %.adoc
21
+ #bundle exec asciidoctor -r ./lib/glob-include-processor.rb -r asciidoctor-rfc -b rfc2 $^ --trace > $@
22
+ bundle exec asciidoctor -r ./lib/glob-include-processor.rb -r asciidoctor-rfc -b rfc3 -a flush-biblio=true $^ --trace > $@
23
+
24
+ %.txt: %.xml
25
+ xml2rfc --text $^ $@
26
+
27
+ %.html: %.xml
28
+ xml2rfc --html $^ $@
29
+
30
+ %.nits: %.txt
31
+ VERSIONED_NAME=`grep :name: $*.adoc | cut -f 2 -d ' '`; \
32
+ cp $^ $${VERSIONED_NAME}.txt && \
33
+ idnits --verbose $${VERSIONED_NAME}.txt > $@ && \
34
+ cp $@ $${VERSIONED_NAME}.nits && \
35
+ cat $${VERSIONED_NAME}.nits
36
+
37
+ open:
38
+ open *.txt
39
+
@@ -1,96 +1,433 @@
1
- # asciidoctor-iso
2
- = Asciidoctor processor for ISO standards
1
+ = AsciiISO: Asciidoctor processor for ISO standards
3
2
 
4
- image:https://img.shields.io/gem/v/asciidoctor-rfc.svg["Gem Version", link="https://rubygems.org/gems/asciidoctor-iso"]
5
- image:https://img.shields.io/travis/riboseinc/asciidoctor-rfc/master.svg["Build Status", link="https://travis-ci.org/riboseinc/asciidoctor-iso"]
6
- image:https://codeclimate.com/github/riboseinc/asciidoctor-rfc/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/riboseinc/asciidoctor-iso"]
3
+ image:https://img.shields.io/gem/v/asciidoctor-iso.svg["Gem Version", link="https://rubygems.org/gems/asciidoctor-iso"]
4
+ image:https://img.shields.io/travis/riboseinc/asciidoctor-iso/master.svg["Build Status", link="https://travis-ci.org/riboseinc/asciidoctor-iso"]
5
+ image:https://codeclimate.com/github/riboseinc/asciidoctor-iso/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/riboseinc/asciidoctor-iso"]
7
6
 
8
- This gem processes http://asciidoctor.org/[Asciidoctor] documents and outputs an XML representation of the document, intended as a document model for ISO International Standards. The XML representation can then be processed in turn to generate PDF or Microsoft Word output (via DocBook).
7
+ WARNING: This gem is still under development.
9
8
 
10
- The document model intends to introduce rigour into the ISO standards authoring process; the existing https://www.iso.org/iso-templates.html[Microsoft Word template from ISO] do not support such rigour down to the element level. The ISO International Standard format is prescribed in http://www.iec.ch/members_experts/refdocs/iec/isoiecdir-2%7Bed7.0%7Den.pdf[ISO/IEC DIR 2 "Principles and rules for the structure and drafting of ISO and IEC documents"], to a level that is amenable to an explicit document model. A formal document model would allow checking for consistency in format and content, and expedite authoring and quality control of ISO standards.
9
+ == Functionality
11
10
 
12
- The document model ("ISO XML") is under development, but it already contains all the markup needed to render the https://www.iso.org/publication/PUB100407.html["Rice document"], the ISO's model document of an international standard. It is expressed as a link:lib/asciidoctor/iso/validate.rnc[Relax NG Compact schema]; actual validation occurs against its link:lib/asciidoctor/iso/validate.rng[full Relax NG counterpart]. A UML representation of the document model is given below. Note that the document model is currently still in the exploratory phase, and will likely be changing significantly.
11
+ This gem processes http://asciidoctor.org/[Asciidoctor] documents following
12
+ a template for generating ISO International Standards. The following
13
+ outputs are generated.
13
14
 
14
- Asciidoctor has been selected as the authoring tool to generate the document model representation of ISO standards. It is a document formatting tool like Markdown and DocBook, which combines the relative ease of use of the former (using relatively lightweight markup), and the rigour and expressively of the latter (it has a well-defined syntax, and was in fact initially developed as a DocBook document authoring tool). Asciidoctor has built-in capability to output Text, DocBook and HTML; so it can be used to preview the file as it is being authored.
15
+ * (Optional) An HTML preview generated directly from the Asciidoctor document,
16
+ using native Asciidocot formatting.
17
+ ** http://asciimath.org[AsciiMathML] is to be used for mathematical formatting.
18
+ The gem uses the https://github.com/asciidoctor/asciimath[Ruby AsciiMath parser],
19
+ which is syntactically stricter than the common MathJax processor;
20
+ if you do not get expected results, try bracketting terms your in AsciiMathML
21
+ expressions.
22
+ * an XML representation of the document, intended as a document model for ISO
23
+ International Standards.
24
+ * The XML representation is processed in turn to generate the following outputs
25
+ as end deliverable ISO standard drafts.
26
+ ** Microsoft Word output (`.doc`), following the style conventions of the
27
+ https://www.iso.org/iso-templates.html[ISO Standard Microsoft Word template].
28
+ ** PDF (forthcoming)
29
+ ** HTML (in development)
15
30
 
16
- Note that in order to generate output close to what is intended, the Asciidoc document includes a fair amount of formatting instructions (e.g. disabling section numbering where appropriate, the titling of Appendixes as Annexes), as well as ISO boilerplate text, and predefined section headers (sections are recognised by fixed titles such as `Normative References`). Authoring ISO standards in this fashion assumes that users will be populating an Asciidoc template, and not removing needed formatting instructions.
31
+ This AsciiDoc syntax for writing ISO standards is hereby named "AsciiISO".
17
32
 
18
- == Features not visible in HTML preview
33
+ == Usage
34
+
35
+ [source,console]
36
+ ----
37
+ $ asciidoctor a.adoc # HTML output of Asciidoc file
38
+ $ asciidoctor -b iso -r 'asciidoctor-iso' a.adoc # ISO XML output,
39
+ ----
40
+
41
+ The initial step is optional, and can be used as a preview of what the gem
42
+ will do; it generates a `{filename}.html` file.
43
+
44
+ When invoked within Asciidoctor, the gem translates the document into
45
+ ISO XML format, and then validates its
46
+ output against the ISO XML document model; errors are reported to console
47
+ against the XML, and are intended for users to check that they have provided
48
+ all necessary components of the document.
49
+
50
+ The gem then converts the XML to Micosoft Word (`{filename}.doc`), HTML (`{filename}.html`),
51
+ and PDF (forthcoming).
52
+
53
+ In the process of generating the Microsoft Word document, the associated
54
+ https://github.com/riboseinc/isodoc[IsoDoc] gem generates temporary files:
55
+ `{filename}.htm` contains the Microsoft Word-specific HTML for inclusion in that file,
56
+ and the `{filename}_files` folder contains any images and headers for the Word
57
+ document.
58
+
59
+ === Content Warnings
60
+
61
+ The gem also realises several format
62
+ checks as prescribed in ISO/IEC DIR 2, and warns the user about them in the
63
+ console:
64
+
65
+ * Numbers with what looks like dots instead of commas for decimal points.
66
+
67
+ * Groups of numbers without spacing for every three digits. (The gem attempts
68
+ to ignore ISO references.)
69
+
70
+ * No space before percent sign.
71
+
72
+ * No bracketing of tolerance in percentage (e.g. `15 ± 7 % .`)
73
+
74
+ * No recommendations, permissions or requirements (detected by keyword) in:
75
+ foreword, scope, introduction, term examples and examples, notes, footnotes.
76
+
77
+ * No subclauses that are the only child of a clause. (In clauses, annexes, or
78
+ scopes.)
79
+
80
+ * 5 levels of subclause nesting. (Never actuated, AsciiDoc only permits 4
81
+ levels of subsections.)
82
+
83
+ * Non-ISO/IEC reference turning up as normative.
84
+
85
+ * Term definition starts with an article, or ends with a period.
86
+
87
+ * Title intro or title part appears in only one of French or English.
88
+
89
+ == Approach
90
+ === Document model
91
+
92
+ The document model ("IsoDoc") used in document generation
93
+ intends to introduce rigour into the ISO
94
+ standards authoring process; the existing
95
+ https://www.iso.org/iso-templates.html[Microsoft Word template from ISO]
96
+ do not support such rigour down to the element level.
97
+
98
+ The ISO International Standard format is prescribed in
99
+ http://www.iec.ch/members_experts/refdocs/iec/isoiecdir-2%7Bed7.0%7Den.pdf[ISO/IEC DIR 2 "Principles and rules for the structure and drafting of ISO and IEC documents"],
100
+ to a level amenable to an explicit document model. A formal document
101
+ model would allow checking for consistency in format and content, and expedite
102
+ authoring and quality control of ISO standards. Authoring standards through a more abstract formal model also permit enhanced functionality such as cross reference link checking and auto numbering of sections, figures, tables and formulas.
103
+
104
+ The document model for ISO Standards specifically is derived from a more general
105
+ https://github.com/riboseinc/isodoc-models[StandardDocument model]. Other
106
+ ISO-like standards can also be derived from this more general model;
107
+ CSD (https://github.com/riboseinc/csd, https://github.com/riboseinc/asciidoctor-csd)
108
+ is one such instance.
109
+
110
+ The document model for ISO Standards is still under development, but it already contains
111
+ all the markup needed to render the
112
+ https://www.iso.org/publication/PUB100407.html["Rice document"], the ISO's
113
+ model document of an international standard, and all the structures described
114
+ in ISO/IEC DIR 2. It is expressed as a
115
+ link:lib/asciidoctor/iso/isostandard.rnc[Relax NG Compact schema]; actual
116
+ validation occurs against its link:lib/asciidoctor/iso/isostandard.rng[full Relax
117
+ NG counterpart].
118
+
119
+ === Asciidoctor
120
+
121
+ Asciidoctor has been selected as the authoring tool to generate the document
122
+ model representation of ISO standards. It is a document formatting tool like
123
+ Markdown and DocBook, which combines the relative ease of use of the former
124
+ (using relatively lightweight markup), and the rigour and expressively of the
125
+ latter (it has a well-defined syntax, and was in fact initially developed as a
126
+ DocBook document authoring tool). Asciidoctor has built-in capability to output
127
+ Text and HTML; so it can be used to preview the file as it is being
128
+ authored. However the gem natively outputs HTML and Word output, so there should
129
+ not be much need for this.
130
+
131
+ In order to generate HTML preview output close to what is intended
132
+ in the ISO standard, the Asciidoc
133
+ document includes a fair amount of formatting instructions (e.g. disabling
134
+ section numbering where appropriate, the titling of Appendixes as Annexes), as
135
+ well as ISO boilerplate text, and predefined section headers (sections are
136
+ recognised by fixed titles such as `Normative References`). Authoring ISO
137
+ standards in this fashion assumes that users will be populating an Asciidoc
138
+ template, and not removing needed formatting instructions.
139
+
140
+ Asciidoctor has some formatting constraints because of its own document model,
141
+ that users need to be aware. For example, Asciidoc has a strict division between
142
+ inline and block elements, which disallows certain kinds of nesting; so a list
143
+ cannot be embedded within a paragraph, it can only constitute its own paragraph
144
+ (though lists themselves can be nested within each other). Asciidoctor also disallows
145
+ multiple paragraphs in footnotes,
146
+ http://discuss.asciidoctor.org/footnotes-with-paragraph-breaks-td4130.html[by design].
147
+ (The document model does not impose this constraint, so you could edit the generated
148
+ XML to break up paragraphs within a footnote.)
149
+
150
+ [[model_additions]]
151
+ === Asciidoctor model additions
152
+
153
+ ==== Paragraph alignment
154
+
155
+ Alignment is defined as an attribute for paragraphs:
156
+
157
+ [source,asciidoctor]
158
+ --
159
+ [align=left]
160
+ This paragraph is aligned left
161
+
162
+ [align=right]
163
+ This paragraph is aligned right
164
+
165
+ [align=center]
166
+ This paragraph is aligned center
167
+
168
+ [align=justified]
169
+ This paragraph is justified, which is the default
170
+ --
171
+
172
+ ==== Dates on reviewer notes
173
+
174
+ Reviewer notes are encoded as sidebars. A date attribute (in ISO 8601 format)
175
+ and a reviewer attribute (naming the reviewer)
176
+ are mandatory for reviewer notes; supplying the time as well as the date
177
+ is optional.
178
+
179
+ [source,asciidoctor]
180
+ --
181
+ [reviewer="Nick Nicholas",date=20180125T0121]
182
+ ****
183
+ I do not agree with this statement.
184
+ ****
185
+ --
186
+
187
+ ==== Strikethrough and Small Caps
188
+
189
+ The following formatting macros are used for strikethrough and small caps text:
190
+
191
+ [source,asciidoctor]
192
+ --
193
+ [strike]#strike through text#
194
+ [smallcap]#small caps text#
195
+ --
196
+
197
+ ==== Count of table header and footer rows
198
+
199
+ In Asciidoc, a table can have at most one header row or footer row. In ISO,
200
+ a nominal single header row is routinely broken up into multiple rows in order
201
+ to accommodate units or symbols, that line up against each other, though
202
+ they are displayed as merged cells with no grid between them. To address this,
203
+ tables can be marked up with an optional `headerrows` attribute:
204
+
205
+ [source,asciidoctor]
206
+ --
207
+ [headerrows=2]
208
+ |===
209
+ .2+|Defect 4+^| Maximum permissible mass fraction of defects in husked rice +
210
+ stem:[w_max]
211
+ | in husked rice | in milled rice (non-glutinous) | in husked parboiled rice | in milled parboiled rice
212
+
213
+ | Extraneous matter: organic footnote:[Organic extraneous matter includes foreign seeds, husks, bran, parts of straw, etc.] | 1,0 | 0,5 | 1,0 | 0,5
214
+ |===
215
+ --
216
+
217
+ ==== Inline clause numbers
218
+
219
+ For some clauses (notably test methods), the clause heading appears inline with the clause, instead of being separated on a different line. This is indicated in Asciidoc by the option
220
+ attribute `inline-header`:
221
+
222
+ [source,asciidoctor]
223
+ --
224
+ [%inline-header]
225
+ [[AnnexA-2-1]]
226
+ ==== Sample divider,
227
+
228
+ consisting of a conical sample divider
229
+ --
230
+
231
+ === Features not visible in HTML preview
232
+
233
+ The gem uses built-in Asciidoc formatting as much as possible, so that users
234
+ can retain the ability to preview documents; for _Terms and Definitions_
235
+ clauses, which have a good deal of explicit structure, macros have been
236
+ introduced for semantic markup (admitted terms, deprecated terms, etc).
19
237
 
20
- The gem uses built-in Asciidoc formatting as much as possible, so that users can retain the ability to preview documents; for _Terms and Definitions_ clauses, which have a good deal of explicit structure, macros have been introduced for semantic markup (admitted terms, deprecated terms, etc). The default HTML output of an Asciidoc-formatted ISO document is quite close to the intended final output, with the following exceptions:
238
+ The default HTML output of an Asciidoc-formatted ISO document is quite close to the
239
+ intended final output, with the following exceptions, and with the additional
240
+ exceptions listed <<model_additions,above>> as markup introduced for ISO markup.
241
+ Note that the final
242
+ outputs of the conversion (Microsoft Word, PDF, HTML) do not have these exceptions,
243
+ and comply with the ISO Standard specifications.
244
+
245
+ * _Terms and Definitions_: each term is marked up as an unnumbered subclause,
246
+ the semantic markup of alternate and other terms is not rendered visually.
247
+
248
+ * _Formulas_: Asciidoctor has no provision for the automated numbering of
249
+ isolated block formulas ("stem"), and does not display the number assigned a
250
+ block formula in its default HTML processor—although it does provide automated
251
+ numbering of examples. Formula numbering is provided in the final outputs
252
+ of the conversion.
253
+
254
+ * _Missing elements_: The document model does not yet include Asciidoc elements
255
+ that do not appear to be relevant to ISO Standards; these will be ignored in
256
+ generating ISO XML. Those elements include:
257
+ ** sidebars (`aside`) (as distinct from warnings),
258
+ ** ASCII art/preformatted text (`literal`) (as distinct from sourcecode listings),
259
+ ** page breaks (`thematic break`).
260
+
261
+ * _Markup_: Some connecting text which is used to convey markup structure is
262
+ left out: in particular, `DEPRECATED` and `SOURCE` (replaced by formatting
263
+ macros).
264
+
265
+ * _Tables_: Table footnotes are treated like all other footnotes: they are
266
+ rendered at the bottom of the document, rather than the bottom of the table,
267
+ and they are not numbered separately.
268
+
269
+ * _Cross-references_: Footnoted cross-references are indicated with the reference
270
+ text `fn` in isolation, or `fn:` as a prefix to the reference text. The default
271
+ HTML processor leaves these as is: if no reference text is given, only `fn`
272
+ will be displayed (though it will still hyperlink to the right reference).
273
+
274
+ * _References_: The convention for references is that ISO documents are cited
275
+ without brackets by ISO number, and optionally year, whether they are normative
276
+ or in the bibliography (e.g. `ISO 20483:2013`); while all other references are
277
+ cited by bracketed number in the bibliography (e.g. `[1]`). The default HTML
278
+ processor treats all references the same, and will bracket them (e.g. `[ISO
279
+ 20483:2013]`). For the same reason, ISO references listed in the bibliography
280
+ will be listed under an ISO reference, rather than a bracketed number.
281
+
282
+ * _References_: References are rendered cited throughout, since they are
283
+ automated. For that reason, if reference is to be made to both an undated and a
284
+ dated version of an ISO reference, these need to be explicitly listed as
285
+ separate references. (This is not done in the Rice model document, which lists
286
+ ISO 6646, but under _Terms and Definitions_ cites the dated ISO 6646:2011.
287
+
288
+ * _References_: ISO references that are undated but published have their date
289
+ indicated under the ISO standards format in an explanatory footnote. Because of
290
+ constraints introduced by Asciidoctor, that explanation is instead given in
291
+ square brackets in Asciidoc format.
292
+
293
+ * _Annexes_: Subheadings cannot preserve subsection numbering, while also
294
+ appearing inline with their text (e.g. Rice document, Annex B.2): they appear
295
+ as headings in separate lines.
296
+
297
+ * _Annexes_: Cross-references to Annex subclauses are automatically prefixed
298
+ with `Clause` rather than `Annex` or nothing.
299
+
300
+ * _Metadata_: Document metadata such as document numbers, technical committees
301
+ and title wording are not rendered in the default HTML output.
302
+
303
+ * _Patent Notice_: Patent notices are treated and rendered as a subsection of
304
+ the introduction, with an explicit subheading.
305
+
306
+ * _Numbering_: The numbering of figures and tables is sequential in the default
307
+ HTML processor: it does not include the Clause or Annex number. This,
308
+ _Figure 1_, not _Figure A.1_.
21
309
 
22
- * _Terms and Definitions_: each term is marked up as an unnumbered subclause, the semantic markup of alternate and other terms is not rendered visually.
23
- * _Formuals_: Asciidoctor has no provision for the automated numbering of isolated block formulas ("stem"), and does not display the number assigned a block formula in its default HTML processor—although it does provide automated numbering of examples. The encoding of formulas may change in future versions, although the final numbering is meant to be provided by downstream tools processing the ISO XML output.
24
- * _Missing elements_: The document model does not yet include Asciidoc elements that do not occur in the Rice document: in particular, source code, definition lists (except when used as keys for formuals or figures), examples (as distinct from figures; examples within _Terms and Definitions_ are catered for), sidebars (as distinct from warnings), quotes.
25
- * _Markup_: Some connecting text which is used to convey markup structure is left out: in particular, `DEPRECATED` and `SOURCE` (replaced by formatting macros).
26
- * _Tables_: Table footnotes are treated like all other footnotes: they are rendered at the bottom of the document, rather than the bottom of the table, and they are not numbered separately.
27
- * _Crossreferences_: Footnoted crossreferences are indicated with the reference text `fn` in isolation, or `fn:` as a prefix to the reference text. The default HTML processor leaves these as is: if no reference text is given, only `fn` will be displayed (though it will still hyperlink to the right reference).
28
- * _References_: The convention for references is that ISO documents are cited without brackets by ISO number, and optionally year, whether they are normative or in the bibliography (e.g. `ISO 20483:2013`); while all other references are cited by bracketed number in the bibliography (e.g. `[1]`). The default HTML processor treats all references the same, and will bracket them (e.g. `[ISO 20483:2013]`). For the same reason, ISO references listed in the bibliography will be listed under an ISO reference, rather than a bracketed number.
29
- * _References_: References are rendered cited throughout, since they are automated. For that reason, if reference is to be made to both an undated and a dated version of an ISO reference, these need to be explicitly listed as separate references. (This is not done in the Rice model document, which lists ISO 6646, but under _Terms and Definitions_ cites the dated ISO 6646:2011.
30
- * _References_: ISO references that are undated but published have their date indicated under the ISO standards format in an explanatory footnote. Because of constraints introduced by Asciidoctor, that explanation is instead given in square brackets in Asciidoc format.
31
- * _Annexes_: Subheadings cannot preserve subsection numbering, while also appearing inline with their text (e.g. Rice document, Annex B.2): they appear as headings in separate lines.
32
- * _Annexes_: Crossreferences to Annex subclauses are automatically prefixed with `Clause` rather than `Annex` or nothing.
33
- * _Metadata_: Document metadata such as document numbers, technical committees and title wording are not rendered in the default HTML output.
34
- * _Patent Notice_: Patent notices are treated and rendered as a subsection of the introduction, with an explicit subheading.
35
- * _Numbering_: The numbering of figures and tables is sequential in the default HTML processor: it does not include the Clause or Annex number. This, _Figure 1_, not _Figure A.1_.
36
310
  * _Notes_: There is no automatic note numbering by the default HTML processor.
37
- * _Keys_: Keys to formulas and figures are expected to be marked up as definition lists consistently, rather than as inline prose.
38
- * _Figures_: Simple figures are marked up as images, figures containing subfigures as examples. Numbering by the default HTML processor may be inconsistent. Subfigures are automatically numbered as independent figures.
39
- * _Markup_: The default HTML processor does not support CSS extensions such as small caps or strike through, though these can be marked up as CSS classes through custom macros in Asciidoc: a custom CSS stylesheet will be needed to render them.
40
311
 
41
- TODO: May need to only encode figures as examples.
312
+ * _Review Notes_: The reviewer on the review note is not displayed.
313
+
314
+ * _Keys_: Keys to formulas and figures are expected to be marked up as
315
+ definition lists consistently, rather than as inline prose.
316
+
317
+ * _Figures_: Simple figures are marked up as images, figures containing
318
+ subfigures as examples. Numbering by the default HTML processor may be
319
+ inconsistent. Subfigures are automatically numbered as independent figures.
320
+
321
+ * _Markup_: The default HTML processor does not support CSS extensions such as
322
+ small caps or strike through, though these can be marked up as CSS classes
323
+ through custom macros in Asciidoctor: a custom CSS stylesheet will be needed to
324
+ render them.
325
+
326
+
42
327
 
43
328
  == Document Attributes
44
329
 
45
- The gem also relies on Asciidoc document attributes to provide necessary metadata about the document. These include:
330
+ The gem relies on Asciidoctor document attributes to provide necessary
331
+ metadata about the document. These include:
46
332
 
47
333
  `:docnumber:`:: The ISO document number (mandatory)
334
+
48
335
  `:tc-docnumber:`:: The document number assigned by the Technical committee
49
- `:ref-docnumber:`:: The reference document number (appearing in page headers)
336
+
50
337
  `:partnumber:`:: The ISO document part number
338
+
51
339
  `:edition:`:: The document edition
340
+
52
341
  `:revdate:`:: The date the document was last updated
53
- `:copyright-year:`:: The year which will be claimed as when the copyright for the document was issued
54
- `:title-intro-en:`:: The introductory component of the English title of the document
55
- `:title-main-en:`:: The main component of the English title of the document (mandatory). (The first line of the Asciidoc document, which contains the title introduced with `=`, is ignored)
342
+
343
+ `:draft:`:: The document draft (used in addition to document stage, for multiple iterations: expected format _X.Y_)
344
+
345
+ `:copyright-year:`:: The year which will be claimed as when the copyright for
346
+ the document was issued
347
+
348
+ `:title-intro-en:`:: The introductory component of the English title of the
349
+ document
350
+
351
+ `:title-main-en:`:: The main component of the English title of the document
352
+ (mandatory). (The first line of the AsciiDoc document, which contains the title
353
+ introduced with `=`, is ignored)
354
+
56
355
  `:title-part-en:`:: The English title of the document part
57
- `:title-intro-fr:`:: The introductory component of the French title of the document. (This document template presupposes authoring in English; a different template will be needed for French, including French titles of document components such as annexes.)
58
- `:title-main-fr:`:: The main component of the French title of the document (mandatory).
356
+
357
+ `:title-intro-fr:`:: The introductory component of the French title of the
358
+ document. (This document template presupposes authoring in English; a different
359
+ template will be needed for French, including French titles of document
360
+ components such as annexes.)
361
+
362
+ `:title-main-fr:`:: The main component of the French title of the document
363
+ (mandatory).
364
+
59
365
  `:title-part-fr:`:: The French title of the document part
60
- `:doctype:`:: The document type (see https://www.iso.org/deliverables-all.html[ISO deliverables: The different types of ISO publications]) (mandatory). The permitted types are: `international-standard, technical-specification, technical-report, publicly-available-specification, international-workshop-agreement, guide`.
61
- `:docstage:`:: The stage code for the document status (see https://www.iso.org/stage-codes.html[International harmonized stage codes])
62
- `:docsubstage:`:: The substage code for the document status (see https://www.iso.org/stage-codes.html[International harmonized stage codes])
63
- `:secretariat:`:: The national body acting as the secretariat for the document in the deafting stage
64
- `:technical-committee-number:`:: The number of the relevant ISO technical committee
65
- `:technical-committee:`:: The name of the relevant ISO technical committee (mandatory)
366
+
367
+ `:doctype:`:: The document type (see
368
+ https://www.iso.org/deliverables-all.html[ISO deliverables: The different types of ISO publications]
369
+ ) (mandatory). The permitted types are:
370
+ `international-standard, technical-specification, technical-report,
371
+ publicly-available-specification, international-workshop-agreement, guide`.
372
+
373
+ `:docstage:`:: The stage code for the document status (see
374
+ https://www.iso.org/stage-codes.html[International harmonized stage codes])
375
+
376
+ `:docsubstage:`:: The substage code for the document status (see
377
+ https://www.iso.org/stage-codes.html[International harmonized stage codes])
378
+
379
+ `:secretariat:`:: The national body acting as the secretariat for the document
380
+ in the deafting stage
381
+
382
+ `:technical-committee-number:`:: The number of the relevant ISO technical
383
+ committee
384
+
385
+ `:technical-committee:`:: The name of the relevant ISO technical committee
386
+ (mandatory)
387
+
66
388
  `:subcommittee-number:`:: The number of the relevant ISO subcommittee
389
+
67
390
  `:subcommittee:`:: The name of the relevant ISO subcommittee
391
+
68
392
  `:workgroup-number:`:: The number of the relevant ISO workgroup
393
+
69
394
  `:workgroup:`:: The name of the relevant ISO workgroup
395
+
70
396
  `:language:` :: The language of the document (`en` or `fr`) (mandatory)
71
397
 
72
- The gem translates the document into ISO XML format, and then validates its output against the ISO XML document model; errors are reported to console against the XML, and are intended for users to check that they have provided all necessary components of the document.
73
398
 
74
- The attribute `:draft:`, if present, includes review notes in the XML output; these are otherwise suppressed.
399
+ The attribute `:draft:`, if present, includes review notes in the XML output;
400
+ these are otherwise suppressed.
75
401
 
76
- == Usage
77
- [source,console]
78
- ----
79
- $ asciidoctor a.adoc # HTML output of Asciidoc file
80
- $ asciidoctor -b iso -r 'asciidoctor-iso' a.adoc # ISO XML output
81
- ----
82
402
 
83
- == Document model
403
+ == Data Models
84
404
 
85
- image::grammar1.gif[]
86
- image::grammar2.gif[]
87
- image::grammar3.gif[]
88
- image::grammar4.gif[]
405
+ The IsoDoc data model (IsoStandardDocument) is instantiated from the
406
+ https://github.com/riboseinc/isodoc-models[StandardDocument model]. For details
407
+ please visit that page.
408
+
409
+ == Code Structure
410
+
411
+ The gem invokes the following other gems as a division of labour.
412
+
413
+ * This gem generates the IsoDoc XML proper
414
+ * https://github.com/riboseinc/isodoc renders IsoDoc XML into HTML
415
+ * https://github.com/riboseinc/html2doc converts HTML into Microsoft Word
416
+ * https://github.com/riboseinc/isodoc-models derives the ISO Standard grammar
417
+ used for validation from the generic IsoDoc grammar
89
418
 
90
419
 
91
420
  == Examples
92
- The gem has been tested to date against the https://www.iso.org/publication/PUB100407.html["Rice document"], the ISO's model document of an international standard. This repository includes:
93
421
 
94
- * the link:spec/examples/rice.adoc[Asciidoc version of the Rice document].
95
- * the link:spec/examples/rice.html[Asciidoc rendering of the Rice document as HTML].
422
+ The gem has been tested to date against the
423
+ https://www.iso.org/publication/PUB100407.html["Rice document"], the ISO's
424
+ model document of an international standard. This repository includes:
425
+
426
+ * the link:spec/examples/rice.adoc[AsciiISO version of the Rice document].
427
+ * the link:spec/examples/rice.preview.html[AsciiISO rendering of the Rice document as an HTML preview]
428
+ (native Asciidoc rendering)
96
429
  * the link:spec/examples/rice.xml[ISO XML rendering of the Rice document].
430
+ * the link:spec/examples/rice.doc[Word .doc rendering of the Rice document].
431
+ * the link:spec/examples/rice.html[HTML rendering of the Rice document].
432
+
433
+