Sha256: 6329fcda23231dd22a289a8cffc7ec5cb68928a0a57f4504c3c4799f211d7bbc

Contents?: true

Size: 943 Bytes

Versions: 10

Compression:

Stored size: 943 Bytes

Contents

module ReverseAsciidoctor
  module Converters
    class Audio < 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, "audio::", src, "[", options(node), "]"].join("")
      end

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

    register :audio, Audio.new
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

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