Class: Asciidoctor::Converter::Base
- Inherits:
-
Object
- Object
- Asciidoctor::Converter::Base
- Includes:
- Asciidoctor::Converter, Logging
- Defined in:
- lib/asciidoctor/converter.rb
Overview
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.
Direct Known Subclasses
CompositeConverter, DocBook5Converter, Html5Converter, ManPageConverter, TemplateConverter
Constant Summary
Constants included from DefaultFactory
Instance Attribute Summary
Attributes included from Asciidoctor::Converter
Instance Method Summary collapse
-
#content_only(node) ⇒ String
Converts the AbstractNode using only its converted content.
-
#convert(node, transform = node.node_name, opts = nil) ⇒ Object
Converts an AbstractNode by delegating to a method that matches the transform value.
- #handles?(transform) ⇒ Boolean
-
#skip(node) ⇒ void
Skips conversion of the AbstractNode.
Methods included from Asciidoctor::Converter
derive_backend_traits, #initialize
Methods included from DefaultFactory
#for, #register, #unregister_all
Methods included from Factory
#converters, #create, create, default, #for, new, #register
Methods included from Logging
#logger, #message_with_context
Instance Method Details
#content_only(node) ⇒ String
Converts the AbstractNode using only its converted content.
405 406 407 |
# File 'lib/asciidoctor/converter.rb', line 405 def content_only node node.content end |
#convert(node, transform = node.node_name, opts = nil) ⇒ Object
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 Asciidoctor::Converter#convert for details about the arguments and return value.
390 391 392 393 394 395 396 |
# 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) ⇒ Boolean
398 399 400 |
# File 'lib/asciidoctor/converter.rb', line 398 def handles? transform respond_to? %(convert_#{transform}) end |
#skip(node) ⇒ void
This method returns an undefined value.
Skips conversion of the AbstractNode.
412 |
# File 'lib/asciidoctor/converter.rb', line 412 def skip node; end |