Sha256: 750f99617d3978897aa02e5b44633499dc6af8119ed2af137656dd9362fa8788

Contents?: true

Size: 1018 Bytes

Versions: 10

Compression:

Stored size: 1018 Bytes

Contents

module ReverseAsciidoctor
  module Converters
    class Video < Base
      def convert(node, state = {})
        autoplay   = node['autoplay']
        loop_attr   = node['loop']
        controls   = node['controls']
        src   = node['src']
        id = node['id']
        anchor = id ? "[[#{id}]]\n" : ""
        title = extract_title(node)
        title = ".#{title}\n" unless title.empty?
        [anchor, title, "video::", src, "[", options(node), "]"].join("")
      end

      def options(node)
        autoplay   = node['autoplay']
        loop_attr   = node['loop']
        controls   = node['controls']
        width   = node['width']
        ret = ""
        if autoplay || loop_attr || controls
          out = []
          out << "autoplay" if autoplay
          out << "loop" if loop_attr
          out << "controls" if controls
          out << "width=#{width}" if width
          ret = %{options="#{out.join(',')}"}
        end
        ret
      end
    end

    register :video, Video.new
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
reverse_adoc-0.2.8 lib/reverse_asciidoctor/converters/video.rb
reverse_adoc-0.2.7 lib/reverse_asciidoctor/converters/video.rb
reverse_adoc-0.2.6 lib/reverse_asciidoctor/converters/video.rb
reverse_adoc-0.2.5 lib/reverse_asciidoctor/converters/video.rb
reverse_adoc-0.2.4 lib/reverse_asciidoctor/converters/video.rb
reverse_adoc-0.2.3 lib/reverse_asciidoctor/converters/video.rb
reverse_asciidoctor-0.2.2 lib/reverse_asciidoctor/converters/video.rb
reverse_asciidoctor-0.2.1 lib/reverse_asciidoctor/converters/video.rb
reverse_asciidoctor-0.2.0 lib/reverse_asciidoctor/converters/video.rb
reverse_asciidoctor-0.1.0 lib/reverse_asciidoctor/converters/video.rb