Sha256: e706ea442a2b8d909c42a01029f8756bf8e7837086aa63618e1e26886ce8b104

Contents?: true

Size: 1.75 KB

Versions: 3

Compression:

Stored size: 1.75 KB

Contents

# encoding: UTF-8
module Asciidoctor
  module Converter; end # required for Opal

  # An abstract base class for defining converters that can be used to convert
  # {AbstractNode} objects in a parsed AsciiDoc document to a backend format
  # such as HTML or DocBook.
  #
  # Concrete subclasses must implement the {#convert} method and, optionally,
  # the {#convert_with_options} method.
  class Converter::Base
    include Logging
    include Converter
  end

  # An abstract base class for built-in {Converter} classes.
  # Does not inherit from Converter.
  class Converter::BuiltIn
    include Logging

    def initialize backend, opts = {}
    end

    # Public: Converts the specified {AbstractNode} using the specified
    # transform and optionally additional options (when not empty).
    #
    # CAUTION: Method that handles the specified transform *may not* accept the
    # second argument with additional options, in which case an {ArgumentError}
    # is raised if the given +opts+ Hash is not nil. The additional options are
    # used in template-based backends to access convert helper methods such as
    # outline.
    #
    # See {Converter#convert} for more details.
    #
    # Returns the [String] result of conversion
    def convert node, transform = nil, opts = {}
      transform ||= node.node_name
      opts.empty? ? (send transform, node) : (send transform, node, opts)
    end

    alias handles? respond_to?

    # Public: Returns the converted content of the {AbstractNode}.
    #
    # Returns the converted [String] content of the {AbstractNode}.
    def content node
      node.content
    end

    alias pass content

    # Public: Skips conversion of the {AbstractNode}.
    #
    # Returns [NilClass]
    def skip node
      nil
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
asciidoctor-1.5.8 lib/asciidoctor/converter/base.rb
asciidoctor-1.5.7.1 lib/asciidoctor/converter/base.rb
asciidoctor-1.5.7 lib/asciidoctor/converter/base.rb