Class: Asciidoctor::Standoc::Yaml2TextPreprocessor

Inherits:
Extensions::Preprocessor
  • Object
show all
Defined in:
lib/asciidoctor/standoc/macros_yaml2text.rb

Constant Summary collapse

BLOCK_START_REGEXP =
/\{(.+?)\.\*,(.+),(.+)\}/
BLOCK_END_REGEXP =
/\A\{[A-Z]+\}\z/

Instance Method Summary collapse

Instance Method Details

#process(document, reader) ⇒ Object

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

73
74
75
76
# File 'lib/asciidoctor/standoc/macros_yaml2text.rb', line 73

def process(document, reader)
  input_lines = reader.readlines.to_enum
  Reader.new(processed_lines(document, input_lines))
end