Sha256: 5766cb2f06aa133a9d00fe244b569f995d9e1648a4cbaf3e4b46d9e80133a399

Contents?: true

Size: 550 Bytes

Versions: 9

Compression:

Stored size: 550 Bytes

Contents

module ReverseAdoc
  module Converters
    class Figure < Base
      def convert(node, state = {})
        id = node['id']
        anchor = id ? "[[#{id}]]\n" : ""
        title = extract_title(node)
        title = ".#{title}\n" unless title.empty?
        "\n\n#{anchor}#{title}====\n" << treat_children(node, state).strip << "\n====\n\n"
      end

      def extract_title(node)
        title = node.at("./figcaption")
        return "" if title.nil?
        treat_children(title, {})
      end
    end

    register :figure, Figure.new
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
reverse_adoc-0.3.7 lib/reverse_adoc/converters/figure.rb
reverse_adoc-0.3.6 lib/reverse_adoc/converters/figure.rb
reverse_adoc-0.3.5 lib/reverse_adoc/converters/figure.rb
reverse_adoc-0.3.4 lib/reverse_adoc/converters/figure.rb
reverse_adoc-0.3.3 lib/reverse_adoc/converters/figure.rb
reverse_adoc-0.3.1 lib/reverse_adoc/converters/figure.rb
reverse_adoc-0.3.0 lib/reverse_adoc/converters/figure.rb
reverse_adoc-0.2.10 lib/reverse_adoc/converters/figure.rb
reverse_adoc-0.2.9 lib/reverse_adoc/converters/figure.rb