Sha256: ab3217f3da69d7b4513fc14b372c2c0e2884ed3390e3a81248fbcab94ebcd37a

Contents?: true

Size: 657 Bytes

Versions: 4

Compression:

Stored size: 657 Bytes

Contents

module ReverseAsciidoctor
  module Converters
    class Img < Base
      def convert(node, state = {})
        alt   = node['alt']
        src   = node['src']
        id = node['id']
        width = node['width']
        height = node['height']
        anchor = id ? "[[#{id}]]\n" : ""
        title = extract_title(node)
        title = ".#{title}\n" unless title.empty?
        attrs = alt
        attrs = "\"\"" if (width || height) && alt.nil?
        attrs += ",#{width}" if width
        attrs += ",#{height}" if width && height
        [anchor, title, "image::", src, "[", attrs, "]"].join("")
      end
    end

    register :img, Img.new
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
reverse_asciidoctor-0.2.2 lib/reverse_asciidoctor/converters/img.rb
reverse_asciidoctor-0.2.1 lib/reverse_asciidoctor/converters/img.rb
reverse_asciidoctor-0.2.0 lib/reverse_asciidoctor/converters/img.rb
reverse_asciidoctor-0.1.0 lib/reverse_asciidoctor/converters/img.rb