asciidoctor-iso 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +7 -10
- data/README.adoc +118 -6
- data/asciidoctor-iso.gemspec +1 -4
- data/lib/asciidoctor-iso.rb +2 -0
- data/lib/asciidoctor/iso/base.rb +20 -95
- data/lib/asciidoctor/iso/blocks.rb +47 -39
- data/lib/asciidoctor/iso/cleanup.rb +25 -97
- data/lib/asciidoctor/iso/cleanup_block.rb +10 -1
- data/lib/asciidoctor/iso/cleanup_ref.rb +100 -0
- data/lib/asciidoctor/iso/converter.rb +5 -2
- data/lib/asciidoctor/iso/front.rb +52 -24
- data/lib/asciidoctor/iso/html/header.html +10 -10
- data/lib/asciidoctor/iso/html/html_iso_intro.html +1 -1
- data/lib/asciidoctor/iso/html/html_iso_titlepage.html +5 -5
- data/lib/asciidoctor/iso/html/htmlstyle.css +0 -21
- data/lib/asciidoctor/iso/html/isodoc.css +13 -28
- data/lib/asciidoctor/iso/html/word_iso_intro.html +2 -2
- data/lib/asciidoctor/iso/html/word_iso_titlepage.html +7 -7
- data/lib/asciidoctor/iso/html/wordstyle.css +998 -0
- data/lib/asciidoctor/iso/inline.rb +128 -0
- data/lib/asciidoctor/iso/isodoc.rng +1516 -0
- data/lib/asciidoctor/iso/isostandard.rnc +38 -39
- data/lib/asciidoctor/iso/isostandard.rng +529 -1276
- data/lib/asciidoctor/iso/isostandard_diff.rnc +40 -56
- data/lib/asciidoctor/iso/lists.rb +30 -28
- data/lib/asciidoctor/iso/macros.rb +37 -0
- data/lib/asciidoctor/iso/section.rb +1 -1
- data/lib/asciidoctor/iso/utils.rb +9 -0
- data/lib/asciidoctor/iso/validate.rb +41 -120
- data/lib/asciidoctor/iso/validate_section.rb +117 -0
- data/lib/asciidoctor/iso/validate_style.rb +5 -7
- data/lib/asciidoctor/iso/version.rb +1 -1
- data/spec/examples/rice.adoc +41 -8
- data/spec/examples/rice.doc +2885 -2859
- data/spec/examples/rice.html +316 -649
- data/spec/examples/rice.preview.html +51 -10
- data/spec/examples/rice.xml +418 -343
- metadata +12 -50
- data/lib/asciidoctor/iso/inline_anchor.rb +0 -59
- data/lib/asciidoctor/iso/validate.make.sh +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81628e6445230282af27ae6ee08a5b1662850618
|
4
|
+
data.tar.gz: 5ec3c5c6573556c7cf6cfb5ebcaa827d728db794
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e79a67ec52c08f26beeda9eca31e38556832ed8eaaa000b42e05fbafc24a59cc96166b81d32b43264432a11e1087862a14fe30dc3ae241a60012bb9ad6f9137e
|
7
|
+
data.tar.gz: 7ee22285f177d6c466cbf7870a4f9e001eda32485a517625afb3df7c37d5f83e51cef712b77569f1bca21323e60a8017a7c02101c68080368956af4f2f7c644f
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
GIT
|
2
2
|
remote: https://github.com/riboseinc/html2doc.git
|
3
|
-
revision:
|
3
|
+
revision: 8a131b82eeecd0c27e4bde873f2ba16d425754d6
|
4
4
|
specs:
|
5
|
-
html2doc (0.0
|
5
|
+
html2doc (0.6.0)
|
6
6
|
asciimath
|
7
7
|
htmlentities (~> 4.3.4)
|
8
8
|
image_size
|
@@ -14,9 +14,9 @@ GIT
|
|
14
14
|
|
15
15
|
GIT
|
16
16
|
remote: https://github.com/riboseinc/isodoc.git
|
17
|
-
revision:
|
17
|
+
revision: 0818963410de3aeb880f263678c47dcadcfe9b50
|
18
18
|
specs:
|
19
|
-
isodoc (0.0
|
19
|
+
isodoc (0.4.0)
|
20
20
|
asciimath
|
21
21
|
html2doc
|
22
22
|
htmlentities (~> 4.3.4)
|
@@ -30,16 +30,13 @@ GIT
|
|
30
30
|
PATH
|
31
31
|
remote: .
|
32
32
|
specs:
|
33
|
-
asciidoctor-iso (0.
|
33
|
+
asciidoctor-iso (0.6.1)
|
34
34
|
asciidoctor (~> 1.5.6)
|
35
|
-
asciimath
|
36
35
|
html2doc
|
37
36
|
htmlentities (~> 4.3.4)
|
38
|
-
|
39
|
-
mime-types
|
37
|
+
isodoc
|
40
38
|
nokogiri (= 1.8.1)
|
41
39
|
ruby-jing
|
42
|
-
ruby-xslt
|
43
40
|
thread_safe
|
44
41
|
uuidtools
|
45
42
|
|
@@ -55,7 +52,7 @@ GEM
|
|
55
52
|
docile (1.1.5)
|
56
53
|
equivalent-xml (0.6.0)
|
57
54
|
nokogiri (>= 1.4.3)
|
58
|
-
ffi (1.9.
|
55
|
+
ffi (1.9.21)
|
59
56
|
formatador (0.2.5)
|
60
57
|
guard (2.14.2)
|
61
58
|
formatador (>= 0.2.4)
|
data/README.adoc
CHANGED
@@ -30,6 +30,10 @@ https://www.iso.org/iso-templates.html[ISO Standard Microsoft Word template].
|
|
30
30
|
|
31
31
|
This AsciiDoc syntax for writing ISO standards is hereby named "AsciiISO".
|
32
32
|
|
33
|
+
This README provides an overview of the functionality of the gem; see also
|
34
|
+
https://github.com/riboseinc/asciidoctor-iso/wiki/Guidance-for-authoring[Guidance for authoring]
|
35
|
+
ISO standards using the gem.
|
36
|
+
|
33
37
|
== Usage
|
34
38
|
|
35
39
|
[source,console]
|
@@ -56,6 +60,7 @@ https://github.com/riboseinc/isodoc[IsoDoc] gem generates temporary files:
|
|
56
60
|
and the `{filename}_files` folder contains any images and headers for the Word
|
57
61
|
document.
|
58
62
|
|
63
|
+
|
59
64
|
=== Content Warnings
|
60
65
|
|
61
66
|
The gem also realises several format
|
@@ -150,6 +155,27 @@ XML to break up paragraphs within a footnote.)
|
|
150
155
|
[[model_additions]]
|
151
156
|
=== Asciidoctor model additions
|
152
157
|
|
158
|
+
=== Term markup
|
159
|
+
|
160
|
+
To ensure the structure of Terms and Definitions is captured accurately, the following
|
161
|
+
macros are defined, and must be used to mark up their respective content:
|
162
|
+
|
163
|
+
`alt:[TERM]`:: for alternative terms
|
164
|
+
`deprecated:[TERM]`:: for deprecated terms
|
165
|
+
`domain:[TERM]`:: for term domains
|
166
|
+
|
167
|
+
The macro contents can contain their own markup.
|
168
|
+
|
169
|
+
[source,asciidoctor]
|
170
|
+
--
|
171
|
+
=== paddy
|
172
|
+
alt:[_paddy_ rice]
|
173
|
+
deprecated:[#[smallcap]#cargo# rice]
|
174
|
+
domain:[rice]
|
175
|
+
|
176
|
+
_paddy_ (<<paddy>>) from which the husk only has been removed
|
177
|
+
--
|
178
|
+
|
153
179
|
==== Paragraph alignment
|
154
180
|
|
155
181
|
Alignment is defined as an attribute for paragraphs:
|
@@ -169,19 +195,45 @@ This paragraph is aligned center
|
|
169
195
|
This paragraph is justified, which is the default
|
170
196
|
--
|
171
197
|
|
172
|
-
====
|
198
|
+
==== Reviewer notes
|
173
199
|
|
174
|
-
Reviewer notes are encoded as sidebars
|
175
|
-
|
176
|
-
|
177
|
-
|
200
|
+
Reviewer notes are encoded as sidebars, and can be separated at a distance from the
|
201
|
+
text they are annotating; the text they are annotating is indicated through anchors.
|
202
|
+
Reviewer notes are only rendered if the document has a `:draft:` attribute.
|
203
|
+
|
204
|
+
The following attributes on reviewer notes are mandatory:
|
205
|
+
|
206
|
+
* `reviewer` attribute (naming the reviewer)
|
207
|
+
* the starting target anchor of the note (`from` attribute)
|
208
|
+
|
209
|
+
The following attributes are optional:
|
210
|
+
|
211
|
+
* `date` attribute, optionally including the time (as xs:date or xs:datetime)
|
212
|
+
* the ending target anchor of the note (`to` attribute)
|
213
|
+
|
214
|
+
The span of text covered by the reviewer note is from the start of the
|
215
|
+
text encompassed by the `from` element, to the end of the text encompassed
|
216
|
+
by the `to` element. If only the `from` element supplied, the reviewer note
|
217
|
+
covers the `from` element. The `from` and `to` elements can be bookmarks,
|
218
|
+
which cover no space.
|
178
219
|
|
179
220
|
[source,asciidoctor]
|
180
221
|
--
|
181
|
-
[
|
222
|
+
[[clause_address_profile_definition]]
|
223
|
+
=== Address Profile Definition (AddressProfileDescription)
|
224
|
+
|
225
|
+
[[para1]]
|
226
|
+
This is a clause address [[A]]profile[[B]] definition
|
227
|
+
|
228
|
+
[reviewer="Nick Nicholas",date=20180125T0121,from=clause_address_profile_definition,to=para1]
|
182
229
|
****
|
183
230
|
I do not agree with this statement.
|
184
231
|
****
|
232
|
+
|
233
|
+
[reviewer="Nick Nicholas",date=20180125T0121,from=A,to=B]
|
234
|
+
****
|
235
|
+
Profile?!
|
236
|
+
****
|
185
237
|
--
|
186
238
|
|
187
239
|
==== Strikethrough and Small Caps
|
@@ -228,6 +280,41 @@ attribute `inline-header`:
|
|
228
280
|
consisting of a conical sample divider
|
229
281
|
--
|
230
282
|
|
283
|
+
==== Bibliographic details
|
284
|
+
|
285
|
+
Citations can include details of where in the document the citation is located; these
|
286
|
+
are entered by suffixing the type of locality, followed by the reference. Multiple
|
287
|
+
instances of locality and reference can be provided, delimited by comma or colon. For
|
288
|
+
example:
|
289
|
+
|
290
|
+
[source,asciidoctor]
|
291
|
+
--
|
292
|
+
<<ISO712,section 5, page 8-10>> # renders as: ISO 712, Section 5, Page 8-10
|
293
|
+
<<ISO712,section 5, page 8-10: 5:8-10>> # renders as ISO 712, 5:8-10
|
294
|
+
<<ISO712,whole>> # renders as: ISO 712, Whole of text
|
295
|
+
--
|
296
|
+
|
297
|
+
The references cannot contain spaces. Any text following the sequence of localities
|
298
|
+
will be displayed instead of the localities.
|
299
|
+
|
300
|
+
==== Block Quotes
|
301
|
+
|
302
|
+
As in normal Asciidoctor, block quotes are preceded with an author and a citation;
|
303
|
+
but the citation is expected to be in the same format as all other citations,
|
304
|
+
a cross-reference optionally followed by text, which may include the bibliographic
|
305
|
+
sections referenced:
|
306
|
+
|
307
|
+
[source,asciidoctor]
|
308
|
+
--
|
309
|
+
[quote, ISO, "ISO7301,section 1"]
|
310
|
+
_____
|
311
|
+
This International Standard gives the minimum specifications for rice (_Oryza sativa_ L.)
|
312
|
+
which is subject to international trade. It is applicable to the following types: husked rice
|
313
|
+
and milled rice, parboiled or not, intended for direct human consumption. It is neither
|
314
|
+
applicable to other products derived from rice, nor to waxy rice (glutinous rice).
|
315
|
+
_____
|
316
|
+
--
|
317
|
+
|
231
318
|
=== Features not visible in HTML preview
|
232
319
|
|
233
320
|
The gem uses built-in Asciidoc formatting as much as possible, so that users
|
@@ -382,23 +469,48 @@ in the deafting stage
|
|
382
469
|
`:technical-committee-number:`:: The number of the relevant ISO technical
|
383
470
|
committee
|
384
471
|
|
472
|
+
`:technical-committee-type:``:: The type of the relevant technical committee. Defaults
|
473
|
+
to `TC` if not supplied. Values: `TC1, `PC`, `JTC`, `JPC`.
|
474
|
+
|
385
475
|
`:technical-committee:`:: The name of the relevant ISO technical committee
|
386
476
|
(mandatory)
|
387
477
|
|
388
478
|
`:subcommittee-number:`:: The number of the relevant ISO subcommittee
|
389
479
|
|
480
|
+
`:subcommittee-type:`:: The type of the relevant ISO subcommittee. Defaults to
|
481
|
+
`SC` if not supplied. Values: `SC`, `JSC`.
|
482
|
+
|
390
483
|
`:subcommittee:`:: The name of the relevant ISO subcommittee
|
391
484
|
|
392
485
|
`:workgroup-number:`:: The number of the relevant ISO workgroup
|
393
486
|
|
487
|
+
`:workgroup-type:`:: The type of the relevant ISO workgroup. Defaults to `WG` if
|
488
|
+
not supplied. Example values: `JWG`, `JAG`, `AG` (advisory group), `AHG`, `SWG`,
|
489
|
+
`SG`, `MA` (maintenance agency), `CORG`, `JCG`, `CAG`
|
490
|
+
|
394
491
|
`:workgroup:`:: The name of the relevant ISO workgroup
|
395
492
|
|
396
493
|
`:language:` :: The language of the document (`en` or `fr`) (mandatory)
|
397
494
|
|
495
|
+
`:publisher:`:: The standards agency publishing the standard; can be multiple
|
496
|
+
(comma-delimited). Defaults to `ISO`.
|
398
497
|
|
399
498
|
The attribute `:draft:`, if present, includes review notes in the XML output;
|
400
499
|
these are otherwise suppressed.
|
401
500
|
|
501
|
+
The document proper can reference the values of document attributes, which is convenient
|
502
|
+
for reusability. For example,
|
503
|
+
the Rice Model document references the editorial groups that have contributed to the
|
504
|
+
document as
|
505
|
+
|
506
|
+
[source,asciidoc]
|
507
|
+
--
|
508
|
+
This document was prepared by Technical Committee ISO/TC {technical-committee-number}, _{technical-committee}_, Subcommittee SC {subcommittee-number}, _{subcommittee}_.
|
509
|
+
--
|
510
|
+
|
511
|
+
If the corresponding document attributes are not populated in the header, then the references
|
512
|
+
themselves will not be populated.
|
513
|
+
|
402
514
|
|
403
515
|
== Data Models
|
404
516
|
|
data/asciidoctor-iso.gemspec
CHANGED
@@ -28,16 +28,13 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
29
29
|
|
30
30
|
spec.add_dependency "asciidoctor", "~> 1.5.6"
|
31
|
-
spec.add_dependency "asciimath"
|
32
31
|
spec.add_dependency "htmlentities", "~> 4.3.4"
|
33
|
-
spec.add_dependency "image_size"
|
34
|
-
spec.add_dependency "mime-types"
|
35
32
|
spec.add_dependency "nokogiri", "= 1.8.1"
|
36
33
|
spec.add_dependency "ruby-jing"
|
37
|
-
spec.add_dependency "ruby-xslt"
|
38
34
|
spec.add_dependency "thread_safe"
|
39
35
|
spec.add_dependency "uuidtools"
|
40
36
|
spec.add_dependency "html2doc"
|
37
|
+
spec.add_dependency "isodoc"
|
41
38
|
|
42
39
|
spec.add_development_dependency "bundler", "~> 1.15"
|
43
40
|
spec.add_development_dependency "byebug", "~> 9.1"
|
data/lib/asciidoctor-iso.rb
CHANGED
data/lib/asciidoctor/iso/base.rb
CHANGED
@@ -10,6 +10,11 @@ require "isodoc"
|
|
10
10
|
module Asciidoctor
|
11
11
|
module ISO
|
12
12
|
module Base
|
13
|
+
Asciidoctor::Extensions.register do
|
14
|
+
inline_macro Asciidoctor::ISO::AltTermInlineMacro
|
15
|
+
inline_macro Asciidoctor::ISO::DeprecatedTermInlineMacro
|
16
|
+
inline_macro Asciidoctor::ISO::DomainTermInlineMacro
|
17
|
+
end
|
13
18
|
|
14
19
|
def content(node)
|
15
20
|
node.content
|
@@ -29,7 +34,7 @@ module Asciidoctor
|
|
29
34
|
def doc_converter
|
30
35
|
IsoDoc::Convert.new(
|
31
36
|
htmlstylesheet: html_doc_path("htmlstyle.css"),
|
32
|
-
wordstylesheet:
|
37
|
+
wordstylesheet: html_doc_path("wordstyle.css"),
|
33
38
|
standardstylesheet: html_doc_path("isodoc.css"),
|
34
39
|
header: html_doc_path("header.html"),
|
35
40
|
htmlcoverpage: html_doc_path("html_iso_titlepage.html"),
|
@@ -49,7 +54,6 @@ module Asciidoctor
|
|
49
54
|
def document(node)
|
50
55
|
init
|
51
56
|
ret1 = makexml(node)
|
52
|
-
validate(ret1)
|
53
57
|
ret = ret1.to_xml(indent: 2)
|
54
58
|
filename = node.attr("docfile").gsub(/\.adoc/, ".xml").
|
55
59
|
gsub(%r{^.*/}, '')
|
@@ -67,6 +71,7 @@ module Asciidoctor
|
|
67
71
|
result = textcleanup(result.flatten * "\n")
|
68
72
|
ret1 = cleanup(Nokogiri::XML(result))
|
69
73
|
ret1.root.add_namespace(nil, "http://riboseinc.com/isoxml")
|
74
|
+
validate(ret1)
|
70
75
|
ret1
|
71
76
|
end
|
72
77
|
|
@@ -75,8 +80,10 @@ module Asciidoctor
|
|
75
80
|
end
|
76
81
|
|
77
82
|
def front(node, xml)
|
78
|
-
|
79
|
-
|
83
|
+
xml.bibdata **attr_code(type: node.attr("doctype")) do |b|
|
84
|
+
metadata node, b
|
85
|
+
end
|
86
|
+
metadata_version(node, xml)
|
80
87
|
end
|
81
88
|
|
82
89
|
def middle(node, xml)
|
@@ -87,17 +94,18 @@ module Asciidoctor
|
|
87
94
|
|
88
95
|
def add_term_source(xml_t, seen_xref, m)
|
89
96
|
attr = { bibitemid: seen_xref.children[0]["target"],
|
90
|
-
format: seen_xref.children[0]["format"]
|
97
|
+
format: seen_xref.children[0]["format"],
|
98
|
+
type: "inline" }
|
91
99
|
xml_t.origin seen_xref.children[0].content, **attr_code(attr)
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
100
|
+
m[:section] && xml_t.isosection do |s|
|
101
|
+
s.reference m[:section].gsub(/ /, "")
|
102
|
+
end
|
103
|
+
m[:text] && xml_t.modification do |mod|
|
104
|
+
mod.p { |p| p << m[:text].sub(/^\s+/, "") }
|
97
105
|
end
|
98
106
|
end
|
99
107
|
|
100
|
-
TERM_REFERENCE_RE_STR = <<~REGEXP
|
108
|
+
TERM_REFERENCE_RE_STR = <<~REGEXP.freeze
|
101
109
|
^(?<xref><xref[^>]+>)
|
102
110
|
(,\s(?<section>[^, ]+))?
|
103
111
|
(,\s(?<text>.*))?
|
@@ -105,7 +113,7 @@ module Asciidoctor
|
|
105
113
|
REGEXP
|
106
114
|
TERM_REFERENCE_RE =
|
107
115
|
Regexp.new(TERM_REFERENCE_RE_STR.gsub(/\s/, "").gsub(/_/, "\\s"),
|
108
|
-
Regexp::IGNORECASE)
|
116
|
+
Regexp::IGNORECASE | Regexp::MULTILINE)
|
109
117
|
|
110
118
|
|
111
119
|
def extract_termsource_refs(text)
|
@@ -128,89 +136,6 @@ module Asciidoctor
|
|
128
136
|
end.join("\n")
|
129
137
|
end
|
130
138
|
|
131
|
-
def paragraph(node)
|
132
|
-
return termsource(node) if node.role == "source"
|
133
|
-
attrs = { align: node.attr("align"),
|
134
|
-
id: Utils::anchor_or_uuid(node) }
|
135
|
-
noko do |xml|
|
136
|
-
xml.p **attr_code(attrs) do |xml_t|
|
137
|
-
xml_t << node.content
|
138
|
-
style(node, Utils::flatten_rawtext(node).join(" "))
|
139
|
-
end
|
140
|
-
end.join("\n")
|
141
|
-
end
|
142
|
-
|
143
|
-
def inline_footnote(node)
|
144
|
-
noko do |xml|
|
145
|
-
@fn_number += 1
|
146
|
-
xml.fn **{reference: @fn_number} do |fn|
|
147
|
-
# TODO multi-paragraph footnotes
|
148
|
-
fn.p { |p| p << node.text }
|
149
|
-
footnote_style(node, node.text)
|
150
|
-
end
|
151
|
-
end.join("\n")
|
152
|
-
end
|
153
|
-
|
154
|
-
def open(node)
|
155
|
-
# open block is a container of multiple blocks,
|
156
|
-
# treated as a single block.
|
157
|
-
# We append each contained block to its parent
|
158
|
-
result = []
|
159
|
-
if node.blocks?
|
160
|
-
node.blocks.each do |b|
|
161
|
-
result << send(b.context, b)
|
162
|
-
end
|
163
|
-
else
|
164
|
-
result = paragraph(node)
|
165
|
-
end
|
166
|
-
result
|
167
|
-
end
|
168
|
-
|
169
|
-
def inline_break(node)
|
170
|
-
noko do |xml|
|
171
|
-
xml << node.text
|
172
|
-
xml.br
|
173
|
-
end.join("\n")
|
174
|
-
end
|
175
|
-
|
176
|
-
def page_break(node)
|
177
|
-
noko do |xml|
|
178
|
-
xml << node.text
|
179
|
-
xml.pagebreak
|
180
|
-
end.join("\n")
|
181
|
-
end
|
182
|
-
|
183
|
-
def thematic_break(node)
|
184
|
-
noko do |xml|
|
185
|
-
xml << node.text
|
186
|
-
xml.hr
|
187
|
-
end.join("\n")
|
188
|
-
end
|
189
|
-
|
190
|
-
def inline_quoted(node)
|
191
|
-
noko do |xml|
|
192
|
-
case node.type
|
193
|
-
when :emphasis then xml.em node.text
|
194
|
-
when :strong then xml.strong node.text
|
195
|
-
when :monospaced then xml.tt node.text
|
196
|
-
when :double then xml << "\"#{node.text}\""
|
197
|
-
when :single then xml << "'#{node.text}'"
|
198
|
-
when :superscript then xml.sup node.text
|
199
|
-
when :subscript then xml.sub node.text
|
200
|
-
when :asciimath then xml.stem node.text, **{ type: "AsciiMath" }
|
201
|
-
else
|
202
|
-
case node.role
|
203
|
-
when "alt" then xml.admitted { |a| a << node.text }
|
204
|
-
when "deprecated" then xml.deprecates { |a| a << node.text }
|
205
|
-
when "domain" then xml.domain { |a| a << node.text }
|
206
|
-
when "strike" then xml.strike node.text
|
207
|
-
when "smallcap" then xml.smallcap node.text
|
208
|
-
else
|
209
|
-
xml << node.text
|
210
|
-
end
|
211
|
-
end
|
212
|
-
end.join
|
213
|
-
end
|
214
139
|
end
|
215
140
|
end
|
216
141
|
end
|
@@ -4,14 +4,29 @@ require "uri"
|
|
4
4
|
module Asciidoctor
|
5
5
|
module ISO
|
6
6
|
module Blocks
|
7
|
+
|
7
8
|
def id_attr(node = nil)
|
8
9
|
{ id: Utils::anchor_or_uuid(node) }
|
9
10
|
end
|
10
11
|
|
12
|
+
def open(node)
|
13
|
+
# open block is a container of multiple blocks,
|
14
|
+
# treated as a single block.
|
15
|
+
# We append each contained block to its parent
|
16
|
+
result = []
|
17
|
+
if node.blocks?
|
18
|
+
node.blocks.each do |b|
|
19
|
+
result << send(b.context, b)
|
20
|
+
end
|
21
|
+
else
|
22
|
+
result = paragraph(node)
|
23
|
+
end
|
24
|
+
result
|
25
|
+
end
|
26
|
+
|
11
27
|
def stem(node)
|
12
28
|
# NOTE: html escaping is performed by Nokogiri
|
13
29
|
stem_content = node.lines.join("\n")
|
14
|
-
|
15
30
|
noko do |xml|
|
16
31
|
xml.formula **id_attr(node) do |s|
|
17
32
|
s.stem stem_content, **{ type: "AsciiMath" }
|
@@ -27,6 +42,8 @@ module Asciidoctor
|
|
27
42
|
reviewer: node.attr("reviewer") || node.attr("source") || "(Unknown)",
|
28
43
|
id: Utils::anchor_or_uuid(node),
|
29
44
|
date: date.gsub(/[:-]/, ""),
|
45
|
+
from: node.attr("from"),
|
46
|
+
to: node.attr("to") || node.attr("from"),
|
30
47
|
}
|
31
48
|
end
|
32
49
|
|
@@ -35,7 +52,7 @@ module Asciidoctor
|
|
35
52
|
content = Utils::flatten_rawtext(node.content).join("\n")
|
36
53
|
noko do |xml|
|
37
54
|
xml.review **attr_code(sidebar_attrs(node)) do |r|
|
38
|
-
r
|
55
|
+
wrap_in_para(node, r)
|
39
56
|
end
|
40
57
|
end
|
41
58
|
end
|
@@ -43,10 +60,7 @@ module Asciidoctor
|
|
43
60
|
def termnote(n)
|
44
61
|
noko do |xml|
|
45
62
|
xml.termnote **id_attr(n) do |ex|
|
46
|
-
|
47
|
-
else
|
48
|
-
ex.p {|p| p << n.content }
|
49
|
-
end
|
63
|
+
wrap_in_para(n, ex)
|
50
64
|
style(n, Utils::flatten_rawtext(n.content).join("\n"))
|
51
65
|
end
|
52
66
|
end.join("\n")
|
@@ -55,10 +69,7 @@ module Asciidoctor
|
|
55
69
|
def note(n)
|
56
70
|
noko do |xml|
|
57
71
|
xml.note **id_attr(n) do |c|
|
58
|
-
|
59
|
-
else
|
60
|
-
c.p { |p| p << n.content }
|
61
|
-
end
|
72
|
+
wrap_in_para(n, c)
|
62
73
|
text = Utils::flatten_rawtext(n.content).join("\n")
|
63
74
|
note_style(n, text)
|
64
75
|
end
|
@@ -79,10 +90,7 @@ module Asciidoctor
|
|
79
90
|
return note(node) if node.attr("name") == "note"
|
80
91
|
noko do |xml|
|
81
92
|
xml.admonition **admonition_attrs(node) do |a|
|
82
|
-
|
83
|
-
else
|
84
|
-
a.p { |p| p << node.content }
|
85
|
-
end
|
93
|
+
wrap_in_para(node, a)
|
86
94
|
end
|
87
95
|
end.join("\n")
|
88
96
|
end
|
@@ -91,10 +99,7 @@ module Asciidoctor
|
|
91
99
|
noko do |xml|
|
92
100
|
xml.termexample **id_attr(node) do |ex|
|
93
101
|
c = node.content
|
94
|
-
|
95
|
-
else
|
96
|
-
ex.p {|p| p << c }
|
97
|
-
end
|
102
|
+
wrap_in_para(node, ex)
|
98
103
|
text = Utils::flatten_rawtext(c).join("\n")
|
99
104
|
termexample_style(node, text)
|
100
105
|
end
|
@@ -107,15 +112,13 @@ module Asciidoctor
|
|
107
112
|
xml.example **id_attr(node) do |ex|
|
108
113
|
content = node.content
|
109
114
|
ex << content
|
110
|
-
text = Utils::flatten_rawtext(content).join("\n")
|
111
|
-
termexample_style(node, text)
|
112
115
|
end
|
113
116
|
end.join("\n")
|
114
117
|
end
|
115
118
|
|
116
119
|
def preamble(node)
|
117
120
|
noko do |xml|
|
118
|
-
xml.
|
121
|
+
xml.foreword do |xml_abstract|
|
119
122
|
xml_abstract.title { |t| t << "Foreword" }
|
120
123
|
content = node.content
|
121
124
|
xml_abstract << content
|
@@ -144,33 +147,38 @@ module Asciidoctor
|
|
144
147
|
end
|
145
148
|
end
|
146
149
|
|
150
|
+
def paragraph(node)
|
151
|
+
return termsource(node) if node.role == "source"
|
152
|
+
attrs = { align: node.attr("align"),
|
153
|
+
id: Utils::anchor_or_uuid(node) }
|
154
|
+
noko do |xml|
|
155
|
+
xml.p **attr_code(attrs) do |xml_t|
|
156
|
+
xml_t << node.content
|
157
|
+
style(node, Utils::flatten_rawtext(node).join(" "))
|
158
|
+
end
|
159
|
+
end.join("\n")
|
160
|
+
end
|
161
|
+
|
147
162
|
def quote_attrs(node)
|
148
|
-
{
|
149
|
-
id: Utils::anchor_or_uuid(node),
|
150
|
-
align: node.attr("align"),
|
151
|
-
}
|
163
|
+
{ id: Utils::anchor_or_uuid(node), align: node.attr("align") }
|
152
164
|
end
|
153
165
|
|
154
166
|
def quote_attribution(node, out)
|
155
|
-
if node.attr("attribution")
|
156
|
-
out.fullname do |f|
|
157
|
-
f.surname { |s| s << node.attr("attribution") }
|
158
|
-
# TODO: will break up into name components
|
159
|
-
end
|
160
|
-
end
|
161
167
|
if node.attr("citetitle")
|
162
|
-
|
168
|
+
m = /^(?<cite>[^,]+)(,(?<text>.*$))?$/.match node.attr("citetitle")
|
169
|
+
out.source m[:text],
|
170
|
+
**attr_code(target: m[:cite], type: "inline")
|
171
|
+
end
|
172
|
+
if node.attr("attribution")
|
173
|
+
out.author { |a| a << node.attr("attribution") }
|
163
174
|
end
|
164
175
|
end
|
165
176
|
|
166
177
|
def quote(node)
|
167
178
|
noko do |xml|
|
168
179
|
xml.quote **attr_code(quote_attrs(node)) do |q|
|
169
|
-
quote_attribution(node,
|
170
|
-
|
171
|
-
else
|
172
|
-
q.p { |p| p << node.content }
|
173
|
-
end
|
180
|
+
quote_attribution(node, q)
|
181
|
+
wrap_in_para(node, q)
|
174
182
|
end
|
175
183
|
end
|
176
184
|
end
|
@@ -179,8 +187,8 @@ module Asciidoctor
|
|
179
187
|
# NOTE: html escaping is performed by Nokogiri
|
180
188
|
noko do |xml|
|
181
189
|
if node.parent.context != :example
|
182
|
-
xml.
|
183
|
-
|
190
|
+
xml.example **id_attr(node) do |e|
|
191
|
+
e.sourcecode **id_attr(node) do |s|
|
184
192
|
s << node.content
|
185
193
|
end
|
186
194
|
end
|