Class: Metanorma::Plugin::Lutaml::LutamlPreprocessor

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

Overview

Class for processing Lutaml files

Constant Summary collapse

REMARKS_ATTRIBUTE =
"remarks"

Instance Method Summary collapse

Instance Method Details

#process(document, reader) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/metanorma/plugin/lutaml/lutaml_preprocessor.rb', line 18

def process(document, reader)
  r = Asciidoctor::PreprocessorNoIfdefsReader.new(document,
                                                  reader.lines)
  input_lines = r.readlines.to_enum

  has_lutaml = input_lines.any? { |line| lutaml?(line) }

  express_indexes = Utils.parse_document_express_indexes(
    document,
    input_lines,
  )

  result_content = process_input_lines(
    document: document,
    input_lines: input_lines,
    express_indexes: express_indexes,
  )

  log(document, result_content) if has_lutaml

  Asciidoctor::PreprocessorNoIfdefsReader.new(document, result_content)
end