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
RENDER_REGEX =
/^glossarist::render\[(.*?)\]$/m
BLOCK_REGEX =
/^\[glossarist,(.+?),(.+?)\]$/m
BIBLIOGRAPHY_REGEX =
/^glossarist::render_bibliography\[(.*?)\]$/m
BIBLIOGRAPHY_ENTRY_REGEX =
/^glossarist::render_bibliography_entry\[(.*?)\]$/m

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ DatasetPreprocessor

Returns a new instance of DatasetPreprocessor.



26
27
28
29
30
31
32
33
34
# File 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb', line 26

def initialize(config = {})
  super
  @config = config
  @datasets = {}
  @title_depth = 2
  @bibliography_renderer = BibliographyRenderer.new
  @seen_glossarist = false
  @context_names = []
end

Instance Method Details

#process(document, reader) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb', line 36

def process(document, reader)
  input_lines = reader.lines.to_enum
  @config[:file_system] = relative_file_path(document, "")
  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