asciidoctor-revealjs 5.0.0.rc1 → 5.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +7 -2
- data/README.adoc +1 -1
- data/asciidoctor-revealjs.gemspec +2 -1
- data/examples/images/sample.svg +27 -0
- data/examples/svg-images-docinfo-revealjs.html +15 -0
- data/examples/svg-images.adoc +41 -0
- data/lib/asciidoctor-revealjs/converter.rb +884 -814
- data/lib/asciidoctor-revealjs/version.rb +1 -1
- data/templates/helpers.rb +105 -1
- data/templates/image.html.slim +1 -16
- data/templates/inline_image.html.slim +1 -20
- metadata +7 -18
data/templates/helpers.rb
CHANGED
@@ -193,6 +193,94 @@ module Slim::Helpers
|
|
193
193
|
end
|
194
194
|
end
|
195
195
|
|
196
|
+
# Retrieves the built-in html5 converter.
|
197
|
+
#
|
198
|
+
# Returns the instance of the Asciidoctor::Converter::Html5Converter
|
199
|
+
# associated with this node.
|
200
|
+
def html5_converter
|
201
|
+
converter.instance_variable_get("@delegate_converter")
|
202
|
+
end
|
203
|
+
|
204
|
+
def convert_inline_image(node = self)
|
205
|
+
target = node.target
|
206
|
+
if (node.type || 'image') == 'icon'
|
207
|
+
if (icons = node.document.attr 'icons') == 'font'
|
208
|
+
i_class_attr_val = %(#{node.attr(:set, 'fa')} fa-#{target})
|
209
|
+
i_class_attr_val = %(#{i_class_attr_val} fa-#{node.attr 'size'}) if node.attr? 'size'
|
210
|
+
if node.attr? 'flip'
|
211
|
+
i_class_attr_val = %(#{i_class_attr_val} fa-flip-#{node.attr 'flip'})
|
212
|
+
elsif node.attr? 'rotate'
|
213
|
+
i_class_attr_val = %(#{i_class_attr_val} fa-rotate-#{node.attr 'rotate'})
|
214
|
+
end
|
215
|
+
attrs = (node.attr? 'title') ? %( title="#{node.attr 'title'}") : ''
|
216
|
+
img = %(<i class="#{i_class_attr_val}"#{attrs}></i>)
|
217
|
+
elsif icons
|
218
|
+
attrs = (node.attr? 'width') ? %( width="#{node.attr 'width'}") : ''
|
219
|
+
attrs = %(#{attrs} height="#{node.attr 'height'}") if node.attr? 'height'
|
220
|
+
attrs = %(#{attrs} title="#{node.attr 'title'}") if node.attr? 'title'
|
221
|
+
img = %(<img src="#{src = node.icon_uri target}" alt="#{encode_attribute_value node.alt}"#{attrs}>)
|
222
|
+
else
|
223
|
+
img = %([#{node.alt}])
|
224
|
+
end
|
225
|
+
else
|
226
|
+
html_attrs = (node.attr? 'width') ? %( width="#{node.attr 'width'}") : ''
|
227
|
+
html_attrs = %(#{html_attrs} height="#{node.attr 'height'}") if node.attr? 'height'
|
228
|
+
html_attrs = %(#{html_attrs} title="#{node.attr 'title'}") if node.attr? 'title'
|
229
|
+
img, src = img_tag(node, target, html_attrs)
|
230
|
+
end
|
231
|
+
img_link(node, src, img)
|
232
|
+
end
|
233
|
+
|
234
|
+
def convert_image(node = self)
|
235
|
+
# When the stretch class is present, block images will take the most space
|
236
|
+
# they can take. Setting width and height can override that.
|
237
|
+
# We pinned the 100% to height to avoid aspect ratio breakage and since
|
238
|
+
# widescreen monitors are the most popular, chances are that height will
|
239
|
+
# be the biggest constraint
|
240
|
+
if node.has_role?('stretch') && !(node.attr?(:width) || node.attr?(:height))
|
241
|
+
height_value = "100%"
|
242
|
+
elsif node.attr? 'height'
|
243
|
+
height_value = node.attr 'height'
|
244
|
+
else
|
245
|
+
height_value = nil
|
246
|
+
end
|
247
|
+
html_attrs = (node.attr? 'width') ? %( width="#{node.attr 'width'}") : ''
|
248
|
+
html_attrs = %(#{html_attrs} height="#{height_value}") if height_value
|
249
|
+
html_attrs = %(#{html_attrs} title="#{node.attr 'title'}") if node.attr? 'title'
|
250
|
+
html_attrs = %(#{html_attrs} style="background: #{node.attr :background}") if node.attr? 'background'
|
251
|
+
img, src = img_tag(node, node.attr('target'), html_attrs)
|
252
|
+
img_link(node, src, img)
|
253
|
+
end
|
254
|
+
|
255
|
+
def img_tag(node = self, target, html_attrs)
|
256
|
+
if ((node.attr? 'format', 'svg') || (target.include? '.svg')) && node.document.safe < ::Asciidoctor::SafeMode::SECURE
|
257
|
+
if node.option? 'inline'
|
258
|
+
img = (html5_converter.read_svg_contents node, target) || %(<span class="alt">#{node.alt}</span>)
|
259
|
+
elsif node.option? 'interactive'
|
260
|
+
fallback = (node.attr? 'fallback') ? %(<img src="#{node.image_uri node.attr 'fallback'}" alt="#{encode_attribute_value node.alt}"#{html_attrs}>) : %(<span class="alt">#{node.alt}</span>)
|
261
|
+
img = %(<object type="image/svg+xml" data="#{src = node.image_uri target}"#{html_attrs}>#{fallback}</object>)
|
262
|
+
else
|
263
|
+
img = %(<img src="#{src = node.image_uri target}" alt="#{encode_attribute_value node.alt}"#{html_attrs}>)
|
264
|
+
end
|
265
|
+
else
|
266
|
+
img = %(<img src="#{src = node.image_uri target}" alt="#{encode_attribute_value node.alt}"#{html_attrs}>)
|
267
|
+
end
|
268
|
+
|
269
|
+
[img, src]
|
270
|
+
end
|
271
|
+
|
272
|
+
# Wrap the <img> element in a <a> element if the link attribute is defined
|
273
|
+
def img_link(node = self, src, content)
|
274
|
+
if (node.attr? 'link') && ((href_attr_val = node.attr 'link') != 'self' || (href_attr_val = src))
|
275
|
+
if (link_preview_value = bool_data_attr :link_preview)
|
276
|
+
data_preview_attr = %( data-preview-link="#{link_preview_value == true ? "" : link_preview_value}")
|
277
|
+
end
|
278
|
+
return %(<a class="image" href="#{href_attr_val}"#{(append_link_constraint_attrs node).join}#{data_preview_attr}>#{content}</a>)
|
279
|
+
end
|
280
|
+
|
281
|
+
content
|
282
|
+
end
|
283
|
+
|
196
284
|
def revealjs_dependencies(document, node, revealjsdir)
|
197
285
|
dependencies = []
|
198
286
|
dependencies << "{ src: '#{revealjsdir}/plugin/zoom/zoom.js', async: true, callback: function () { Reveal.registerPlugin(RevealZoom) } }" unless (node.attr? 'revealjs_plugin_zoom', 'disabled')
|
@@ -201,7 +289,6 @@ module Slim::Helpers
|
|
201
289
|
dependencies.join(",\n ")
|
202
290
|
end
|
203
291
|
|
204
|
-
|
205
292
|
# Between delimiters (--) is code taken from asciidoctor-bespoke 1.0.0.alpha.1
|
206
293
|
# Licensed under MIT, Copyright (C) 2015-2016 Dan Allen and the Asciidoctor Project
|
207
294
|
#--
|
@@ -276,6 +363,23 @@ module Slim::Helpers
|
|
276
363
|
nil
|
277
364
|
end
|
278
365
|
|
366
|
+
# Copied from asciidoctor/lib/asciidoctor/converter/html5.rb (method is private)
|
367
|
+
def append_link_constraint_attrs node, attrs = []
|
368
|
+
rel = 'nofollow' if node.option? 'nofollow'
|
369
|
+
if (window = node.attributes['window'])
|
370
|
+
attrs << %( target="#{window}")
|
371
|
+
attrs << (rel ? %( rel="#{rel} noopener") : ' rel="noopener"') if window == '_blank' || (node.option? 'noopener')
|
372
|
+
elsif rel
|
373
|
+
attrs << %( rel="#{rel}")
|
374
|
+
end
|
375
|
+
attrs
|
376
|
+
end
|
377
|
+
|
378
|
+
# Copied from asciidoctor/lib/asciidoctor/converter/html5.rb (method is private)
|
379
|
+
def encode_attribute_value val
|
380
|
+
(val.include? '"') ? (val.gsub '"', '"') : val
|
381
|
+
end
|
382
|
+
|
279
383
|
# Copied from asciidoctor/lib/asciidoctor/converter/semantic-html5.rb which is not yet shipped
|
280
384
|
# @todo remove this code when the new converter becomes available in the main gem
|
281
385
|
def generate_authors node
|
data/templates/image.html.slim
CHANGED
@@ -1,21 +1,6 @@
|
|
1
|
-
- width = (attr? :width) ? (attr :width) : nil
|
2
|
-
- height = (attr? :height) ? (attr :height) : nil
|
3
|
-
|
4
|
-
/ When the stretch class is present, block images will take the most space
|
5
|
-
/ they can take. Setting width and height can override that.
|
6
|
-
/ We pinned the 100% to height to avoid aspect ratio breakage and since
|
7
|
-
/ widescreen monitors are the most popular, chances are that height will
|
8
|
-
/ be the biggest constraint
|
9
|
-
- if (has_role? 'stretch') && !((attr? :width) || (attr? :height))
|
10
|
-
- height = "100%"
|
11
|
-
|
12
1
|
- unless attributes[1] == 'background' || attributes[1] == 'canvas'
|
13
2
|
- inline_style = [("text-align: #{attr :align}" if attr? :align),("float: #{attr :float}" if attr? :float)].compact.join('; ')
|
14
3
|
= html_tag('div', { :id => @id, :class => ['imageblock', role, ('fragment' if (option? :step) || (attr? 'step'))], :style => inline_style }.merge(data_attrs(@attributes)))
|
15
|
-
|
16
|
-
a.image href=(attr :link) target=(attr :window) data-preview-link=(bool_data_attr :link_preview)
|
17
|
-
img src=image_uri(attr :target) alt=(attr :alt) width=(width) height=(height) style=((attr? :background) ? "background: #{attr :background}" : nil)
|
18
|
-
- else
|
19
|
-
img src=image_uri(attr :target) alt=(attr :alt) width=(width) height=(height) style=((attr? :background) ? "background: #{attr :background}" : nil)
|
4
|
+
= convert_image
|
20
5
|
- if title?
|
21
6
|
.title=captioned_title
|
@@ -1,21 +1,2 @@
|
|
1
1
|
= html_tag('span', { :class => [@type, role, ('fragment' if (option? :step) || (attr? 'step'))], :style => ("float: #{attr :float}" if attr? :float) }.merge(data_attrs(@attributes)))
|
2
|
-
|
3
|
-
- style_class = [(attr :set, 'fa'), "fa-#{@target}", ("fa-#{attr :size}" if attr? :size), ("fa-rotate-#{attr :rotate}" if attr? :rotate), ("fa-flip-#{attr :flip}" if attr? :flip)]
|
4
|
-
- if attr? :link
|
5
|
-
a.image href=(attr :link) target=(attr :window) data-preview-link=(bool_data_attr :link_preview)
|
6
|
-
i class=style_class title=(attr :title)
|
7
|
-
- else
|
8
|
-
i class=style_class title=(attr :title)
|
9
|
-
- elsif @type == 'icon' && !(@document.attr? :icons)
|
10
|
-
- if attr? :link
|
11
|
-
a.image href=(attr :link) target=(attr :window) data-preview-link=(bool_data_attr :link_preview)
|
12
|
-
|[#{attr :alt}]
|
13
|
-
- else
|
14
|
-
|[#{attr :alt}]
|
15
|
-
- else
|
16
|
-
- src = (@type == 'icon' ? (icon_uri @target) : (image_uri @target))
|
17
|
-
- if attr? :link
|
18
|
-
a.image href=(attr :link) target=(attr :window) data-preview-link=(bool_data_attr :link_preview)
|
19
|
-
img src=src alt=(attr :alt) width=(attr :width) height=(attr :height) title=(attr :title)
|
20
|
-
- else
|
21
|
-
img src=src alt=(attr :alt) width=(attr :width) height=(attr :height) title=(attr :title)
|
2
|
+
= convert_inline_image
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asciidoctor-revealjs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Olivier Bilodeau
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -44,20 +44,6 @@ dependencies:
|
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: 13.0.0
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: asciidoctor-doctest
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - '='
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: 2.0.0.beta.7
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - '='
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: 2.0.0.beta.7
|
61
47
|
- !ruby/object:Gem::Dependency
|
62
48
|
name: minitest
|
63
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -257,6 +243,7 @@ files:
|
|
257
243
|
- examples/images/flock-of-seagulls_daniel-simion.mp3
|
258
244
|
- examples/images/meme-2.jpg
|
259
245
|
- examples/images/meme-7.png
|
246
|
+
- examples/images/sample.svg
|
260
247
|
- examples/images/web_surfing_time.gif
|
261
248
|
- examples/issue-grid-layout-images.adoc
|
262
249
|
- examples/keyboard-shortcuts.adoc
|
@@ -345,6 +332,8 @@ files:
|
|
345
332
|
- examples/source-rouge.adoc
|
346
333
|
- examples/speaker-notes.adoc
|
347
334
|
- examples/steps.adoc
|
335
|
+
- examples/svg-images-docinfo-revealjs.html
|
336
|
+
- examples/svg-images.adoc
|
348
337
|
- examples/tables-styles.adoc
|
349
338
|
- examples/text-alignments.adoc
|
350
339
|
- examples/text-formatting.adoc
|
@@ -423,9 +412,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
423
412
|
version: '0'
|
424
413
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
425
414
|
requirements:
|
426
|
-
- - "
|
415
|
+
- - ">="
|
427
416
|
- !ruby/object:Gem::Version
|
428
|
-
version:
|
417
|
+
version: '0'
|
429
418
|
requirements: []
|
430
419
|
rubygems_version: 3.1.6
|
431
420
|
signing_key:
|