Class: Metanorma::Plugin::Lutaml::BaseStructuredTextPreprocessor

Inherits:
Asciidoctor::Extensions::Preprocessor
  • Object
show all
Includes:
Utils
Defined in:
lib/metanorma/plugin/lutaml/base_structured_text_preprocessor.rb

Overview

Base class for processing structured data blocks(yaml, json)

Constant Summary collapse

BLOCK_START_REGEXP =
/\{(.+?)\.\*,(.+),(.+)\}/.freeze
BLOCK_END_REGEXP =
/\A\{[A-Z]+\}\z/.freeze
LOAD_FILE_REGEXP =
/{% assign (.*) = (.*) \| load_file %}/.freeze
INCLUDE_PATH_OPTION =
"include_path"
TEMPLATE_OPTION =
"template"

Constants included from Utils

Utils::LUTAML_EXP_IDX_TAG

Instance Method Summary collapse

Methods included from Utils

create_liquid_environment, load_express_from_folder, load_express_from_index, load_express_repo_from_cache, load_express_repo_from_path, load_express_repositories, notify_render_errors, parse_document_express_indexes, processed_lines, relative_file_path, render_liquid_string, save_express_repo_to_cache

Instance Method Details

#process(document, reader) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/metanorma/plugin/lutaml/base_structured_text_preprocessor.rb', line 24

def process(document, reader)
  r = Asciidoctor::PreprocessorNoIfdefsReader
    .new(document, reader.lines)
  input_lines = r.readlines
  Metanorma::Plugin::Lutaml::SourceExtractor
    .extract(document, input_lines)
  result_content = processed_lines(document, input_lines.to_enum)
  Asciidoctor::PreprocessorNoIfdefsReader.new(document, result_content)
end