class Metanorma::Plugin::Datastruct::Json2TextPreprocessor

Public Class Methods

new(config = {}) click to toggle source

search document for block `yaml2text`

after that take template from block and read file into this template
example:
  [yaml2text,foobar.yaml]
  ----
  === {item.name}
  {item.desc}

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

with content of `foobar.yaml` file equal to:
  - name: spaghetti
    desc: wheat noodles of 9mm diameter
    symbol: SPAG
    symbol_def: the situation is message like spaghetti at a kid's

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

  SPAG:: the situation is message like spaghetti at a kid's meal
Calls superclass method
# File lib/metanorma/plugin/datastruct/json2_text_preprocessor.rb, line 33
def initialize(config = {})
  super
  @config[:block_name] = "json2text"
end

Protected Instance Methods

content_from_file(document, file_path) click to toggle source
# File lib/metanorma/plugin/datastruct/json2_text_preprocessor.rb, line 40
def content_from_file(document, file_path)
  JSON.parse(File.read(relative_file_path(document, file_path),
                       encoding: "UTF-8"))
end