Module: Asciidoctor::Reducer
- Defined in:
- lib/asciidoctor/reducer/version.rb,
lib/asciidoctor/reducer/extensions.rb,
lib/asciidoctor/reducer/preprocessor.rb,
lib/asciidoctor/reducer/tree_processor.rb,
lib/asciidoctor/reducer/header_attribute_tracker.rb,
lib/asciidoctor/reducer/include_mapper/extension.rb,
lib/asciidoctor/reducer/include_directive_tracker.rb,
lib/asciidoctor/reducer/conditional_directive_tracker.rb,
lib/asciidoctor/reducer/cli.rb,
lib/asciidoctor/reducer/api.rb
Defined Under Namespace
Modules: Cli, ConditionalDirectiveTracker, Extensions, HeaderAttributeTracker, IncludeDirectiveTracker Classes: IncludeMapper, Preprocessor, TreeProcessor
Constant Summary collapse
- VERSION =
'1.1.0'
Class Method Summary collapse
-
.reduce(input, opts = {}) ⇒ Asciidoctor::Document?
Reduces the AsciiDoc source and either returns the reduced Asciidoctor::Document or writes the source to a file.
-
.reduce_file(input_file, opts = {}) ⇒ Asciidoctor::Document?
Reduces the AsciiDoc file and either returns the reduced Asciidoctor::Document or writes the source to a file.
Class Method Details
.reduce(input, opts = {}) ⇒ Asciidoctor::Document?
Reduces the AsciiDoc source and either returns the reduced Asciidoctor::Document or writes the source to a file.
This method accepts all the options supported by Asciidoctor.load.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/asciidoctor/reducer/api.rb', line 19 def reduce input, opts = {} opts = opts&.merge || {} if (extension_registry = Extensions.prepare_registry opts[:extension_registry] || opts[:extensions]) opts[:extension_registry] = extension_registry end opts[:safe] ||= :safe to = opts.delete :to case input when ::File doc = ::Asciidoctor.load_file input, opts when ::Pathname doc = ::Asciidoctor.load_file input.to_path, opts else doc = ::Asciidoctor.load input, opts end write doc, to end |
.reduce_file(input_file, opts = {}) ⇒ Asciidoctor::Document?
Reduces the AsciiDoc file and either returns the reduced Asciidoctor::Document or writes the source to a file.
This method accepts all the options supported by Asciidoctor.load.
46 47 48 |
# File 'lib/asciidoctor/reducer/api.rb', line 46 def reduce_file input_file, opts = {} reduce (::Pathname.new input_file), opts end |