metanorma-standoc 1.3.8 → 1.3.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +8 -8
- data/lib/asciidoctor/standoc/biblio.rng +1 -1
- data/lib/asciidoctor/standoc/blocks.rb +34 -71
- data/lib/asciidoctor/standoc/front.rb +2 -1
- data/lib/asciidoctor/standoc/inline.rb +32 -0
- data/lib/asciidoctor/standoc/lists.rb +16 -6
- data/lib/asciidoctor/standoc/section.rb +10 -0
- data/lib/metanorma/standoc/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0e0ef43dc360bd20733a52cc9e810116b6f558b580b3a5c13d4f9f3c53ac04d
|
4
|
+
data.tar.gz: 2d617c3cd329788c18a43fdf73bdae8332d9b49e65506d5752ebf9f1bd557722
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2490c762b3f8ded3402d554a175aa438e6e2dfde6064d421de8d61504f5d400e0763eaa925e810169e27ab1d1a4328c52bc319e7e3908b7dcc67f1907626ea0b
|
7
|
+
data.tar.gz: d379114d13c65074d39ad217f78f22a3b568e692b42da7490db95f2eb835a5f1ade2eac4fa0e39af3247b6bda94920b7938852a555d369e9b41dc07ecb178af4
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
metanorma-standoc (1.3.
|
4
|
+
metanorma-standoc (1.3.9)
|
5
5
|
asciidoctor (~> 2.0.0)
|
6
6
|
concurrent-ruby
|
7
7
|
html2doc (~> 0.9.0)
|
@@ -32,9 +32,9 @@ GEM
|
|
32
32
|
docile (1.3.2)
|
33
33
|
equivalent-xml (0.6.0)
|
34
34
|
nokogiri (>= 1.4.3)
|
35
|
-
faraday (0.17.
|
35
|
+
faraday (0.17.1)
|
36
36
|
multipart-post (>= 1.2, < 3)
|
37
|
-
ffi (1.11.
|
37
|
+
ffi (1.11.3)
|
38
38
|
formatador (0.2.5)
|
39
39
|
gb-agencies (0.0.6)
|
40
40
|
guard (2.16.1)
|
@@ -64,7 +64,7 @@ GEM
|
|
64
64
|
iev (0.2.3)
|
65
65
|
nokogiri (>= 1.10.4)
|
66
66
|
image_size (2.0.2)
|
67
|
-
isodoc (1.0.
|
67
|
+
isodoc (1.0.9)
|
68
68
|
asciimath
|
69
69
|
html2doc (~> 0.9.0)
|
70
70
|
htmlentities (~> 4.3.4)
|
@@ -83,7 +83,7 @@ GEM
|
|
83
83
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
84
84
|
rb-inotify (~> 0.9, >= 0.9.10)
|
85
85
|
lumberjack (1.0.13)
|
86
|
-
metanorma (0.3.
|
86
|
+
metanorma (0.3.18)
|
87
87
|
asciidoctor
|
88
88
|
htmlentities
|
89
89
|
method_source (0.9.2)
|
@@ -100,7 +100,7 @@ GEM
|
|
100
100
|
nenv (~> 0.1)
|
101
101
|
shellany (~> 0.0)
|
102
102
|
optout (0.0.2)
|
103
|
-
parallel (1.19.
|
103
|
+
parallel (1.19.1)
|
104
104
|
parser (2.6.5.0)
|
105
105
|
ast (~> 2.4.0)
|
106
106
|
powerpack (0.1.2)
|
@@ -113,7 +113,7 @@ GEM
|
|
113
113
|
rb-fsevent (0.10.3)
|
114
114
|
rb-inotify (0.10.0)
|
115
115
|
ffi (~> 1.0)
|
116
|
-
relaton (0.5.
|
116
|
+
relaton (0.5.16)
|
117
117
|
relaton-calconnect (~> 0.1.0)
|
118
118
|
relaton-gb (~> 0.6.0)
|
119
119
|
relaton-iec (~> 0.4.0)
|
@@ -146,7 +146,7 @@ GEM
|
|
146
146
|
isoics (~> 0.1.6)
|
147
147
|
relaton-bib (~> 0.3.0)
|
148
148
|
ruby_deep_clone (~> 0.8.0)
|
149
|
-
relaton-itu (0.3.
|
149
|
+
relaton-itu (0.3.10)
|
150
150
|
relaton-iso-bib (~> 0.3.0)
|
151
151
|
relaton-nist (0.3.8)
|
152
152
|
relaton-bib (~> 0.3.0)
|
@@ -1,7 +1,5 @@
|
|
1
1
|
require "htmlentities"
|
2
2
|
require "uri"
|
3
|
-
require "mime/types"
|
4
|
-
require "base64"
|
5
3
|
|
6
4
|
module Asciidoctor
|
7
5
|
module Standoc
|
@@ -23,8 +21,6 @@ module Asciidoctor
|
|
23
21
|
subsequence: node.attr("subsequence") )
|
24
22
|
end
|
25
23
|
|
26
|
-
# open block is a container of multiple blocks,
|
27
|
-
# treated as a single block.
|
28
24
|
# We append each contained block to its parent
|
29
25
|
def open(node)
|
30
26
|
role = node.role || node.attr("style")
|
@@ -37,9 +33,13 @@ module Asciidoctor
|
|
37
33
|
result
|
38
34
|
end
|
39
35
|
|
36
|
+
def literal_attrs(node)
|
37
|
+
attr_code(id_attr(node))
|
38
|
+
end
|
39
|
+
|
40
40
|
def literal(node)
|
41
41
|
noko do |xml|
|
42
|
-
xml.figure **
|
42
|
+
xml.figure **literal_attrs(node) do |f|
|
43
43
|
figure_title(node, f)
|
44
44
|
f.pre node.lines.join("\n"), **{ id: Utils::anchor_or_uuid }
|
45
45
|
end
|
@@ -57,19 +57,15 @@ module Asciidoctor
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def sidebar_attrs(node)
|
60
|
-
|
61
|
-
date += "T00:00:00Z" unless /T/.match date
|
62
|
-
{ reviewer: node.attr("reviewer") || node.attr("source") || "(Unknown)",
|
63
|
-
id: Utils::anchor_or_uuid(node),
|
64
|
-
date: date,
|
60
|
+
todo_attrs(node).merge(attr_code(
|
65
61
|
from: node.attr("from"),
|
66
|
-
to: node.attr("to") || node.attr("from")
|
62
|
+
to: node.attr("to") || node.attr("from") ))
|
67
63
|
end
|
68
64
|
|
69
65
|
def sidebar(node)
|
70
66
|
return unless draft?
|
71
67
|
noko do |xml|
|
72
|
-
xml.review **
|
68
|
+
xml.review **(sidebar_attrs(node)) do |r|
|
73
69
|
wrap_in_para(node, r)
|
74
70
|
end
|
75
71
|
end
|
@@ -78,14 +74,15 @@ module Asciidoctor
|
|
78
74
|
def todo_attrs(node)
|
79
75
|
date = node.attr("date") || Date.today.iso8601.gsub(/\+.*$/, "")
|
80
76
|
date += "T00:00:00Z" unless /T/.match date
|
81
|
-
|
77
|
+
attr_code(
|
82
78
|
id: Utils::anchor_or_uuid(node),
|
83
|
-
|
79
|
+
reviewer: node.attr("reviewer") || node.attr("source") || "(Unknown)",
|
80
|
+
date: date )
|
84
81
|
end
|
85
82
|
|
86
83
|
def todo(node)
|
87
84
|
noko do |xml|
|
88
|
-
xml.review **
|
85
|
+
xml.review **(todo_attrs(node)) do |r|
|
89
86
|
wrap_in_para(node, r)
|
90
87
|
end
|
91
88
|
end
|
@@ -100,11 +97,6 @@ module Asciidoctor
|
|
100
97
|
end
|
101
98
|
|
102
99
|
def note(n)
|
103
|
-
a = noko do |xml|
|
104
|
-
xml.note **id_attr(n) do |c|
|
105
|
-
wrap_in_para(n, c)
|
106
|
-
end
|
107
|
-
end
|
108
100
|
noko do |xml|
|
109
101
|
xml.note **id_attr(n) do |c|
|
110
102
|
wrap_in_para(n, c)
|
@@ -119,7 +111,7 @@ module Asciidoctor
|
|
119
111
|
name = t if type.casecmp(t).zero?
|
120
112
|
end
|
121
113
|
end
|
122
|
-
|
114
|
+
attr_code(id: Utils::anchor_or_uuid(node), type: name)
|
123
115
|
end
|
124
116
|
|
125
117
|
def admonition(node)
|
@@ -161,82 +153,53 @@ module Asciidoctor
|
|
161
153
|
end.join("\n")
|
162
154
|
end
|
163
155
|
|
156
|
+
def example_attrs(node)
|
157
|
+
attr_code(id_unnum_attr(node))
|
158
|
+
end
|
159
|
+
|
164
160
|
def example_proper(node)
|
165
161
|
noko do |xml|
|
166
|
-
xml.example **
|
162
|
+
xml.example **example_attrs(node) do |ex|
|
167
163
|
node.title.nil? or ex.name { |name| name << node.title }
|
168
164
|
wrap_in_para(node, ex)
|
169
165
|
end
|
170
166
|
end.join("\n")
|
171
167
|
end
|
172
168
|
|
173
|
-
def preamble(node)
|
174
|
-
noko do |xml|
|
175
|
-
xml.foreword do |xml_abstract|
|
176
|
-
xml_abstract.title { |t| t << (node.blocks[0].title || "Foreword") }
|
177
|
-
content = node.content
|
178
|
-
xml_abstract << content
|
179
|
-
end
|
180
|
-
end.join("\n")
|
181
|
-
end
|
182
|
-
|
183
|
-
def datauri(uri)
|
184
|
-
return uri if /^data:/.match(uri)
|
185
|
-
types = MIME::Types.type_for(@localdir + uri)
|
186
|
-
type = types ? types.first.to_s : 'text/plain; charset="utf-8"'
|
187
|
-
bin = File.open(@localdir + uri, 'rb') {|io| io.read}
|
188
|
-
data = Base64.strict_encode64(bin)
|
189
|
-
"data:#{type};base64,#{data}"
|
190
|
-
end
|
191
|
-
|
192
|
-
def image_attributes(node)
|
193
|
-
uri = node.image_uri (node.attr("target") || node.target)
|
194
|
-
types = /^data:/.match(uri) ? datauri2mime(uri) : MIME::Types.type_for(uri)
|
195
|
-
type = types.first.to_s
|
196
|
-
uri = uri.sub(%r{^data:image/\*;}, "data:#{type};")
|
197
|
-
{ src: @datauriimage ? datauri(uri) : uri,
|
198
|
-
id: Utils::anchor_or_uuid,
|
199
|
-
mimetype: type,
|
200
|
-
height: node.attr("height") || "auto",
|
201
|
-
width: node.attr("width") || "auto" ,
|
202
|
-
filename: node.attr("filename"),
|
203
|
-
title: node.attr("titleattr"),
|
204
|
-
alt: node.alt == node.attr("default-alt") ? nil : node.alt }
|
205
|
-
end
|
206
|
-
|
207
169
|
def figure_title(node, f)
|
208
170
|
return if node.title.nil?
|
209
171
|
f.name { |name| name << node.title }
|
210
172
|
end
|
211
173
|
|
174
|
+
def figure_attrs(node)
|
175
|
+
attr_code(id_unnum_attr(node))
|
176
|
+
end
|
177
|
+
|
212
178
|
def image(node)
|
213
179
|
noko do |xml|
|
214
|
-
xml.figure **
|
180
|
+
xml.figure **figure_attrs(node) do |f|
|
215
181
|
figure_title(node, f)
|
216
|
-
f.image **
|
182
|
+
f.image **(image_attributes(node))
|
217
183
|
end
|
218
184
|
end
|
219
185
|
end
|
220
186
|
|
221
|
-
def
|
222
|
-
|
223
|
-
|
224
|
-
end.join("")
|
187
|
+
def para_attrs(node)
|
188
|
+
attr_code(align: node.attr("align"),
|
189
|
+
id: Utils::anchor_or_uuid(node))
|
225
190
|
end
|
226
191
|
|
227
192
|
def paragraph(node)
|
228
193
|
return termsource(node) if node.role == "source"
|
229
|
-
attrs = { align: node.attr("align"),
|
230
|
-
id: Utils::anchor_or_uuid(node) }
|
231
194
|
noko do |xml|
|
232
|
-
xml.p **
|
195
|
+
xml.p **para_attrs(node) do |xml_t|
|
233
196
|
xml_t << node.content
|
234
197
|
end
|
235
198
|
end.join("\n")
|
236
199
|
end
|
237
200
|
|
238
201
|
def quote_attrs(node)
|
239
|
-
|
202
|
+
attr_code(id: Utils::anchor_or_uuid(node), align: node.attr("align"))
|
240
203
|
end
|
241
204
|
|
242
205
|
def quote_attribution(node, out)
|
@@ -252,7 +215,7 @@ module Asciidoctor
|
|
252
215
|
|
253
216
|
def quote(node)
|
254
217
|
noko do |xml|
|
255
|
-
xml.quote **
|
218
|
+
xml.quote **(quote_attrs(node)) do |q|
|
256
219
|
quote_attribution(node, q)
|
257
220
|
wrap_in_para(node, q)
|
258
221
|
end
|
@@ -260,15 +223,15 @@ module Asciidoctor
|
|
260
223
|
end
|
261
224
|
|
262
225
|
def listing_attrs(node)
|
263
|
-
|
264
|
-
|
265
|
-
|
226
|
+
attr_code(lang: node.attr("language"),
|
227
|
+
id: Utils::anchor_or_uuid(node),
|
228
|
+
filename: node.attr("filename"))
|
266
229
|
end
|
267
230
|
|
268
231
|
# NOTE: html escaping is performed by Nokogiri
|
269
232
|
def listing(node)
|
270
233
|
fragment = ::Nokogiri::XML::Builder.new do |xml|
|
271
|
-
xml.sourcecode **
|
234
|
+
xml.sourcecode **(listing_attrs(node)) do |s|
|
272
235
|
figure_title(node, s)
|
273
236
|
s << node.content
|
274
237
|
end
|
@@ -190,7 +190,8 @@ module Asciidoctor
|
|
190
190
|
end
|
191
191
|
|
192
192
|
def relation_normalise(type)
|
193
|
-
type.sub(/-by$/, "By").sub(/-of$/, "Of").sub(/-from$/, "From")
|
193
|
+
type.sub(/-by$/, "By").sub(/-of$/, "Of").sub(/-from$/, "From").
|
194
|
+
sub(/-in$/, "In")
|
194
195
|
end
|
195
196
|
|
196
197
|
def metadata_getrelation(node, xml, type)
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require "asciidoctor/extensions"
|
2
2
|
require "htmlentities"
|
3
3
|
require "unicode2latex"
|
4
|
+
require "mime/types"
|
5
|
+
require "base64"
|
4
6
|
|
5
7
|
module Asciidoctor
|
6
8
|
module Standoc
|
@@ -152,6 +154,36 @@ module Asciidoctor
|
|
152
154
|
end
|
153
155
|
end.join
|
154
156
|
end
|
157
|
+
|
158
|
+
def datauri(uri)
|
159
|
+
return uri if /^data:/.match(uri)
|
160
|
+
types = MIME::Types.type_for(@localdir + uri)
|
161
|
+
type = types ? types.first.to_s : 'text/plain; charset="utf-8"'
|
162
|
+
bin = File.open(@localdir + uri, 'rb') {|io| io.read}
|
163
|
+
data = Base64.strict_encode64(bin)
|
164
|
+
"data:#{type};base64,#{data}"
|
165
|
+
end
|
166
|
+
|
167
|
+
def image_attributes(node)
|
168
|
+
uri = node.image_uri (node.attr("target") || node.target)
|
169
|
+
types = /^data:/.match(uri) ? datauri2mime(uri) : MIME::Types.type_for(uri)
|
170
|
+
type = types.first.to_s
|
171
|
+
uri = uri.sub(%r{^data:image/\*;}, "data:#{type};")
|
172
|
+
attr_code(src: @datauriimage ? datauri(uri) : uri,
|
173
|
+
id: Utils::anchor_or_uuid,
|
174
|
+
mimetype: type,
|
175
|
+
height: node.attr("height") || "auto",
|
176
|
+
width: node.attr("width") || "auto" ,
|
177
|
+
filename: node.attr("filename"),
|
178
|
+
title: node.attr("titleattr"),
|
179
|
+
alt: node.alt == node.attr("default-alt") ? nil : node.alt)
|
180
|
+
end
|
181
|
+
|
182
|
+
def inline_image(node)
|
183
|
+
noko do |xml|
|
184
|
+
xml.image **(image_attributes(node))
|
185
|
+
end.join("")
|
186
|
+
end
|
155
187
|
end
|
156
188
|
end
|
157
189
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require "pp"
|
2
|
-
|
3
1
|
module Asciidoctor
|
4
2
|
module Standoc
|
5
3
|
module Lists
|
@@ -14,10 +12,14 @@ module Asciidoctor
|
|
14
12
|
end
|
15
13
|
end
|
16
14
|
|
15
|
+
def ul_attr(node)
|
16
|
+
attr_code(id_attr(node))
|
17
|
+
end
|
18
|
+
|
17
19
|
def ulist(node)
|
18
20
|
return reference(node) if in_norm_ref? || in_biblio?
|
19
21
|
noko do |xml|
|
20
|
-
xml.ul **
|
22
|
+
xml.ul **ul_attr(node) do |xml_ul|
|
21
23
|
node.items.each do |item|
|
22
24
|
li(xml_ul, item)
|
23
25
|
end
|
@@ -33,10 +35,14 @@ module Asciidoctor
|
|
33
35
|
style
|
34
36
|
end
|
35
37
|
|
38
|
+
def ol_attr(node)
|
39
|
+
attr_code(id: Utils::anchor_or_uuid(node),
|
40
|
+
type: olist_style(node.style))
|
41
|
+
end
|
42
|
+
|
36
43
|
def olist(node)
|
37
44
|
noko do |xml|
|
38
|
-
xml.ol **
|
39
|
-
type: olist_style(node.style)) do |xml_ol|
|
45
|
+
xml.ol **ol_attr(node) do |xml_ol|
|
40
46
|
node.items.each { |item| li(xml_ol, item) }
|
41
47
|
end
|
42
48
|
end.join("\n")
|
@@ -62,9 +68,13 @@ module Asciidoctor
|
|
62
68
|
end
|
63
69
|
end
|
64
70
|
|
71
|
+
def dl_attr(node)
|
72
|
+
attr_code(id_attr(node))
|
73
|
+
end
|
74
|
+
|
65
75
|
def dlist(node)
|
66
76
|
noko do |xml|
|
67
|
-
xml.dl **
|
77
|
+
xml.dl **dl_attr(node) do |xml_dl|
|
68
78
|
node.items.each do |terms, dd|
|
69
79
|
dt(terms, xml_dl)
|
70
80
|
dd(dd, xml_dl)
|
@@ -85,6 +85,16 @@ module Asciidoctor
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
+
def preamble(node)
|
89
|
+
noko do |xml|
|
90
|
+
xml.foreword do |xml_abstract|
|
91
|
+
xml_abstract.title { |t| t << (node.blocks[0].title || "Foreword") }
|
92
|
+
content = node.content
|
93
|
+
xml_abstract << content
|
94
|
+
end
|
95
|
+
end.join("\n")
|
96
|
+
end
|
97
|
+
|
88
98
|
def abstract_parse(attrs, xml, node)
|
89
99
|
xml.abstract **attr_code(attrs) do |xml_section|
|
90
100
|
xml_section << node.content
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-standoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.9
|
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-11-
|
11
|
+
date: 2019-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|