Class: Sourcerer::PlainTextConverter
- Inherits:
-
Asciidoctor::Converter::Base
- Object
- Asciidoctor::Converter::Base
- Sourcerer::PlainTextConverter
- Defined in:
- lib/sourcerer/plaintext_converter.rb
Overview
A custom Asciidoctor converter that outputs plain text.
It is registered for the "plaintext" backend and can be used to extract
the raw text content or attributes from an AsciiDoc document.
Instance Method Summary collapse
-
#convert(node, _transform = nil, _opts = {}) ⇒ String
The main entry point for the converter.
Instance Method Details
#convert(node, _transform = nil, _opts = {}) ⇒ String
The main entry point for the converter.
It is called by Asciidoctor to convert a node.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/sourcerer/plaintext_converter.rb', line 22 def convert node, _transform = nil, _opts = {} if respond_to?("convert_#{node.node_name}", true) send("convert_#{node.node_name}", node) elsif node.respond_to?(:content) node.content.to_s elsif node.respond_to?(:text) node.text.to_s else '' end end |