Class: Metanorma::Plugin::Glossarist::DatasetPreprocessor

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

Constant Summary collapse

DATASET_ATTR_REGEX =
/^:glossarist-dataset:\s*(.*?)$/m
IMPORT_REGEX =
/^glossarist::import\[(.*?)\]$/m
IMPORT_SECTIONS_REGEX =
/^glossarist::import_sections\[(.*?)\]$/m
RENDER_REGEX =
/^glossarist::render\[(.*?)\]$/m
BLOCK_REGEX =
/^\[glossarist,(.+?),(.+?)\]$/m
BIBLIOGRAPHY_REGEX =
/^glossarist::render_bibliography\[(.*?)\]$/m
BIBLIOGRAPHY_ENTRY_REGEX =
/^glossarist::render_bibliography_entry\[(.*?)\]$/m
BIB_ANCHOR_REGEX =
/^\*\s*\[\[\[([^,]+)/

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ DatasetPreprocessor

Returns a new instance of DatasetPreprocessor.



21
22
23
24
# File 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb', line 21

def initialize(config = {})
  super
  @config = config
end

Instance Method Details

#process(document, reader) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb', line 26

def process(document, reader)
  input_lines = reader.lines.to_enum
  @config[:file_system] = relative_file_path(document, "")
  @registry = DatasetRegistry.new
  @renderer = TemplateRenderer.new(file_system: @config[:file_system])
  @rendered_concepts = []
  @title_depth = 2
  @existing_bib_anchors = []
  @seen_glossarist = false

  processed_doc = prepare_document(document, input_lines)
  log(document, processed_doc.to_s) if @seen_glossarist
  Asciidoctor::PreprocessorReader.new(document,
                                      processed_doc.to_s.split("\n"))
end