Class: Metanorma::Plugin::Lutaml::Json2TextPreprocessor

Inherits:
BaseStructuredTextPreprocessor show all
Includes:
Content
Defined in:
lib/metanorma/plugin/lutaml/json2_text_preprocessor.rb

Constant Summary

Constants inherited from BaseStructuredTextPreprocessor

BaseStructuredTextPreprocessor::BLOCK_END_REGEXP, BaseStructuredTextPreprocessor::BLOCK_START_REGEXP, BaseStructuredTextPreprocessor::INCLUDE_PATH_OPTION, BaseStructuredTextPreprocessor::LOAD_FILE_REGEXP, BaseStructuredTextPreprocessor::TEMPLATE_OPTION

Constants included from Utils

Utils::LUTAML_EXP_IDX_TAG

Instance Method Summary collapse

Methods inherited from BaseStructuredTextPreprocessor

#process

Methods included from Utils

create_liquid_environment, error_signature, 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

Constructor Details

#initialize(config = {}) ⇒ Json2TextPreprocessor

search document for block json2text after that take template from block and read file into this template example: [json2text,foobar.json] ----

=== {item.name}
{item.desc}

{item.symbol}:: {item.symbol_def}
----

with content of `foobar.json` file equal to:
{
  "name": "spaghetti",
  "desc": "wheat noodles of 9mm diameter".
  "symbol": "SPAG",
  "symbol_def": "the situation is message like spaghetti",
}

will produce:
=== spaghetti
wheat noodles of 9mm diameter

SPAG:: the situation is message like spaghetti


34
35
36
37
# File 'lib/metanorma/plugin/lutaml/json2_text_preprocessor.rb', line 34

def initialize(config = {})
  super
  @config[:block_name] = "json2text"
end