asciidoctor-iso 0.10.1 → 0.10.2

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.
@@ -1,279 +0,0 @@
1
- default namespace = "http://riboseinc.com/isoxml"
2
-
3
- # grammar {
4
-
5
- start = iso-standard
6
-
7
- iso-standard =
8
- element iso-standard {
9
- #title+, status, creator, language, script, type, id, version?, copyright, sections
10
- bibdata, version?, sections+
11
- }
12
-
13
- language =
14
- element language { ( "en" | "fr" ) }
15
-
16
- script =
17
- element script { "Latn" }
18
-
19
- # draft into isodoc? To replace version/version?
20
- version =
21
- element version {
22
- edition?,
23
- revision-date?,
24
- draft?
25
- }
26
-
27
- draft = element draft {text}
28
-
29
- # TODO to docidentifier
30
- #id =
31
- #element id {
32
- #documentnumber,
33
- #tc-documentnumber?
34
- #}
35
-
36
- # add type to docidentifier in isodoc?
37
- docidentifier =
38
- element docidentifier {
39
- ( text | documentnumber | tc-documentnumber )
40
- }
41
-
42
- # TODO to orgname
43
- #creator =
44
- #element creator {
45
- #attribute role { text },
46
- #technical-committee,
47
- #subcommittee?,
48
- #workgroup?,
49
- #secretariat?
50
- #}
51
-
52
- organization =
53
- element organization {
54
- orgname, uri?, org-identifier*, contact*,
55
- technical-committee?, subcommittee?, workgroup?, secretariat?
56
- }
57
-
58
- # Do not constrain in XML: add to validation
59
- # type =
60
- # element type {
61
- # ( "international-standard" | "technical-specification" |
62
- # "technical-report" | "publicly-available-specification" |
63
- # "international-workshop-agreement" | "guide" )
64
- # }
65
-
66
- status =
67
- element status {
68
- FormattedString |
69
- ( stage, substage? )
70
- }
71
-
72
- stage =
73
- element stage {
74
- ("00" | "10" | "20" | "30" | "40" | "50" | "60" | "90" | "95" )
75
- }
76
-
77
- substage =
78
- element substage {
79
- ("00" | "20" | "60" | "90" | "92" | "93" | "98" | "99" )
80
- }
81
-
82
- documentnumber =
83
- element project-number {
84
- attribute part { xsd:int }?,
85
- xsd:int
86
- }
87
-
88
- tc-documentnumber =
89
- element tc-document-number {
90
- xsd:int
91
- }
92
-
93
- technical-committee =
94
- element technical-committee {
95
- attribute number { xsd:int }?,
96
- text
97
- }
98
-
99
- subcommittee =
100
- element subcommittee {
101
- attribute number { xsd:int }?,
102
- text
103
- }
104
-
105
- workgroup =
106
- element workgroup {
107
- attribute number { xsd:int }?,
108
- text
109
- }
110
-
111
- secretariat =
112
- element secretariat { text }
113
-
114
- btitle =
115
- element title {
116
- text |
117
- ( title-intro?, title-main, title-part? )
118
- }
119
-
120
- title-intro =
121
- element title-intro { text }
122
-
123
- title-main =
124
- element title-main { text }
125
-
126
- title-part =
127
- element title-part { text }
128
-
129
- sections =
130
- element sections {
131
- content, content?,
132
- clause, references, terms, clause+,
133
- annex*, references?
134
- }
135
-
136
- references =
137
- element references {
138
- attribute id { xsd:ID }?,
139
- section-title?,
140
- bibitem*,
141
- references*
142
- }
143
-
144
- terms =
145
- element terms {
146
- attribute id { xsd:ID }?,
147
- section-title?,
148
- # boilerplate
149
- paragraph-with-footnote*, ul?,
150
- (term+ | terms? )
151
- }
152
-
153
- term =
154
- element term {
155
- attribute id { xsd:ID }?,
156
- preferred, admitted*, deprecates*,
157
- termdomain?, definition, termnote*, termexample*, termsource*
158
- }
159
-
160
- definition =
161
- element definition {
162
- ( paragraph | figure | formula )+
163
- }
164
-
165
- origin =
166
- element origin {
167
- attribute citeas { text },
168
- CitationType
169
- }
170
-
171
- clause-hanging-paragraph-with-footnote =
172
- element subsection {
173
- attribute id { xsd:ID }?,
174
- attribute inline-header { xsd:boolean } ? ,
175
- section-title?,
176
- # allow hanging paragraphs in annexes: they introduce lists
177
- BasicBlock*,
178
- clause-hanging-paragraph-with-footnote*
179
- }
180
-
181
- annex =
182
- element annex {
183
- attribute id { xsd:ID }?,
184
- attribute inline-header { xsd:boolean }?,
185
- attribute subtype { "normative" | "informative" }?,
186
- section-title?,
187
- # allow hanging paragraps in annexes: they introduce lists
188
- #( paragraph-with-footnote | table | note | formula | admonition | ol | ul | dl | figure | quote | sourcecode | review | example )*,
189
- BasicBlock*,
190
- clause-hanging-paragraph-with-footnote*
191
- }
192
-
193
- figure =
194
- element figure {
195
- attribute id { xsd:ID },
196
- tname?,
197
- ( image | figure+ ),
198
- fn*,
199
- dl?,
200
- note*
201
- }
202
-
203
- li =
204
- element li {
205
- #( paragraph-with-footnote | table | note | formula | admonition | ol | ul | dl | quote | sourcecode | review | example )+
206
- BasicBlock+
207
- # exclude figures?
208
- }
209
-
210
- dd =
211
- element dd {
212
- #( paragraph-with-footnote | table | note | formula | admonition | ol | ul | dl | quote | sourcecode | review | example )*
213
- # exclude figures?
214
- BasicBlock
215
- }
216
-
217
- admonition =
218
- element admonition {
219
- attribute id { xsd:ID },
220
- attribute type {
221
- ( "danger" | "caution" | "warning" | "important" | "safety precautions" )},
222
- paragraph-with-footnote+
223
- }
224
-
225
- xref =
226
- element xref {
227
- attribute target { xsd:IDREF },
228
- text
229
- }
230
-
231
- hyperlink =
232
- element link {
233
- attribute target {xsd:anyURI},
234
- text
235
- }
236
-
237
- thead =
238
- element thead { tr+ }
239
-
240
- td =
241
- element td {
242
- attribute colspan { text }?,
243
- attribute rowspan { text }?,
244
- attribute align { "left" | "right" | "center" }?,
245
- (
246
- (TextElement | fn | review )* |
247
- paragraph-with-footnote+
248
- )
249
- }
250
-
251
- th =
252
- element th {
253
- attribute colspan { text }?,
254
- attribute rowspan { text }?,
255
- attribute align { "left" | "right" | "center" }?,
256
- (
257
- (TextElement | fn | review )* |
258
- paragraph-with-footnote+
259
- )
260
- }
261
-
262
- table-note = element note {
263
- attribute id { xsd:ID }?,
264
- paragraph
265
- }
266
-
267
-
268
- Clause-Section =
269
- attribute id { xsd:ID }?,
270
- attribute inline-header { xsd:boolean }?,
271
- section-title?,
272
- (
273
- BasicBlock+ |
274
- clause-subsection+
275
- )
276
-
277
- # }
278
-
279
-
@@ -1,87 +0,0 @@
1
- require "pp"
2
-
3
- module Asciidoctor
4
- module ISO
5
- module Lists
6
- def li(xml_ul, item)
7
- xml_ul.li do |xml_li|
8
- if item.blocks?
9
- xml_li.p(**id_attr(item)) { |t| t << item.text }
10
- xml_li << item.content
11
- else
12
- xml_li.p(**id_attr(item)) { |p| p << item.text }
13
- end
14
- end
15
- end
16
-
17
- def ulist(node)
18
- return reference(node) if in_norm_ref? || in_biblio?
19
- noko do |xml|
20
- xml.ul **id_attr(node) do |xml_ul|
21
- node.items.each do |item|
22
- li(xml_ul, item)
23
- end
24
- end
25
- end.join("\n")
26
- end
27
-
28
- def olist_style(style)
29
- return "alphabet" if style == "loweralpha"
30
- return "roman" if style == "lowerroman"
31
- return "roman_upper" if style == "upperroman"
32
- return "alphabet_upper" if style == "upperalpha"
33
- style
34
- end
35
-
36
- def olist(node)
37
- noko do |xml|
38
- xml.ol **attr_code(id: Utils::anchor_or_uuid(node),
39
- type: olist_style(node.style)) do |xml_ol|
40
- node.items.each { |item| li(xml_ol, item) }
41
- end
42
- end.join("\n")
43
- end
44
-
45
- def dt(terms, xml_dl)
46
- terms.each_with_index do |dt, idx|
47
- xml_dl.dt { |xml_dt| xml_dt << dt.text }
48
- if idx < terms.size - 1
49
- xml_dl.dd
50
- end
51
- end
52
- end
53
-
54
- def dd(dd, xml_dl)
55
- if dd.nil?
56
- xml_dl.dd
57
- return
58
- end
59
- xml_dl.dd do |xml_dd|
60
- xml_dd.p { |t| t << dd.text } if dd.text?
61
- xml_dd << dd.content if dd.blocks?
62
- end
63
- end
64
-
65
- def dlist(node)
66
- noko do |xml|
67
- xml.dl **id_attr(node) do |xml_dl|
68
- node.items.each do |terms, dd|
69
- dt(terms, xml_dl)
70
- dd(dd, xml_dl)
71
- end
72
- end
73
- end.join("\n")
74
- end
75
-
76
- def colist(node)
77
- noko do |xml|
78
- node.items.each_with_index do |item, i|
79
- xml.annotation **attr_code(id: i + 1) do |xml_li|
80
- xml_li.p { |p| p << item.text }
81
- end
82
- end
83
- end.join("\n")
84
- end
85
- end
86
- end
87
- end
@@ -1,95 +0,0 @@
1
- require "asciidoctor/extensions"
2
- module Asciidoctor
3
- module ISO
4
- class AltTermInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
5
- use_dsl
6
- named :alt
7
- parse_content_as :text
8
- using_format :short
9
-
10
- def process(parent, _target, attrs)
11
- out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
12
- %{<admitted>#{out}</admitted>}
13
- end
14
- end
15
-
16
- class DeprecatedTermInlineMacro <
17
- Asciidoctor::Extensions::InlineMacroProcessor
18
- use_dsl
19
- named :deprecated
20
- parse_content_as :text
21
- using_format :short
22
-
23
- def process(parent, _target, attrs)
24
- out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
25
- %{<deprecates>#{out}</deprecates>}
26
- end
27
- end
28
-
29
- class DomainTermInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
30
- use_dsl
31
- named :domain
32
- parse_content_as :text
33
- using_format :short
34
-
35
- def process(parent, _target, attrs)
36
- out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
37
- %{<domain>#{out}</domain>}
38
- end
39
- end
40
-
41
- class PlantUMLBlockMacroBackend
42
- # https://stackoverflow.com/questions/2108727/which-in-ruby-checking-if-program-exists-in-path-from-ruby
43
- def self.plantuml_installed?
44
- cmd = "plantuml"
45
- exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
46
- ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
47
- exts.each do |ext|
48
- exe = File.join(path, "#{cmd}#{ext}")
49
- return exe if File.executable?(exe) && !File.directory?(exe)
50
- end
51
- end
52
- nil
53
- end
54
-
55
- def self.generate_file parent, reader
56
- src = reader.source
57
- reader.lines.first.sub(/\s+$/, "") != "@startuml" or
58
- src = "@startuml\n#{src}\n@enduml\n"
59
- filename = parent.document.reader.lineno
60
- system "mkdir -p plantuml"
61
- File.open("plantuml/#{filename}.pml", "w") { |f| f.write src }
62
- system "plantuml plantuml/#{filename}.pml"
63
- filename
64
- end
65
-
66
- def self.generate_attrs attrs
67
- through_attrs = %w(id align float title role width height alt).
68
- inject({}) do |memo, key|
69
- memo[key] = attrs[key] if attrs.has_key? key
70
- memo
71
- end
72
- end
73
- end
74
-
75
- class PlantUMLBlockMacro < Asciidoctor::Extensions::BlockProcessor
76
- use_dsl
77
- named :plantuml
78
- on_context :literal
79
- parse_content_as :raw
80
-
81
- def process(parent, reader, attrs)
82
- if PlantUMLBlockMacroBackend.plantuml_installed?
83
- filename = PlantUMLBlockMacroBackend.generate_file parent, reader
84
- through_attrs = PlantUMLBlockMacroBackend.generate_attrs attrs
85
- through_attrs["target"] = "plantuml/#{filename}.png"
86
- create_image_block parent, through_attrs
87
- else
88
- warn "PlantUML not installed"
89
- # attrs.delete(1) : remove the style attribute
90
- create_listing_block parent, reader.source, attrs.reject { |k, v| k == 1 }
91
- end
92
- end
93
- end
94
- end
95
- end