class Asciidoctor::Converter::Base

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.

Public Instance Methods

content_only(node) click to toggle source

Public: Converts the {AbstractNode} using only its converted content.

Returns the converted [String] content.

# File lib/asciidoctor/converter.rb, line 405
def content_only node
  node.content
end
convert(node, transform = node.node_name, opts = nil) click to toggle source

Public: Converts an {AbstractNode} by delegating to a method that matches the transform value.

This method looks for a method whose name matches the transform prefixed with “convert_” to dispatch to. If the opts argument is non-nil, this method assumes the dispatch method accepts two arguments, the node and an options Hash. The options Hash may be used by converters to delegate back to the top-level converter. Currently, this feature is used for the outline transform. If the opts argument is nil, this method assumes the dispatch method accepts the node as its only argument.

See {Converter#convert} for details about the arguments and return value.

# File lib/asciidoctor/converter.rb, line 390
def convert node, transform = node.node_name, opts = nil
  opts ? (send 'convert_' + transform, node, opts) : (send 'convert_' + transform, node)
rescue
  raise unless ::NoMethodError === (ex = $!) && ex.receiver == self && ex.name.to_s == transform
  logger.warn %(missing convert handler for #{ex.name} node in #{@backend} backend (#{self.class}))
  nil
end
handles?(transform) click to toggle source
# File lib/asciidoctor/converter.rb, line 398
def handles? transform
  respond_to? %(convert_#{transform})
end
skip(node;) click to toggle source

Public: Skips conversion of the {AbstractNode}.

Returns nothing.

# File lib/asciidoctor/converter.rb, line 412
def skip node; end