Class: Metanorma::Plugin::Glossarist::DatasetPreprocessor
- Inherits:
-
Asciidoctor::Extensions::Preprocessor
- Object
- Asciidoctor::Extensions::Preprocessor
- Metanorma::Plugin::Glossarist::DatasetPreprocessor
- Includes:
- Liquid::CustomFilters::Filters
- Defined in:
- lib/metanorma/plugin/glossarist/dataset_preprocessor.rb
Constant Summary collapse
- GLOSSARIST_DATASET_REGEX =
/^:glossarist-dataset:\s*(.*?)$/m.freeze
- GLOSSARIST_IMPORT_REGEX =
/^glossarist::import\[(.*?)\]$/m.freeze
- GLOSSARIST_RENDER_REGEX =
/^glossarist::render\[(.*?)\]$/m.freeze
- GLOSSARIST_BLOCK_REGEX =
/^\[glossarist,(.+?),(.+?)\]$/m.freeze
- GLOSSARIST_BIBLIOGRAPHY_REGEX =
rubocop:disable Layout/LineLength
/^glossarist::render_bibliography\[(.*?)\]$/m.freeze
- GLOSSARIST_BIBLIOGRAPHY_ENTRY_REGEX =
rubocop:disable Layout/LineLength
/^glossarist::render_bibliography_entry\[(.*?)\]$/m.freeze
Constants included from Liquid::CustomFilters::Filters
Liquid::CustomFilters::Filters::REF_REGEX
Instance Method Summary collapse
-
#initialize(config = {}) ⇒ DatasetPreprocessor
constructor
Search document for the following blocks - :glossarist-dataset: dataset1:./dataset1;dataset2:./dataset2 This will load ‘glossarist` concepts from `./dataset1` path into `dataset1` and concepts from `./dataset2` path into `dataset2`, These can then be used anywhere in the document like {dataset1{dataset1.concept_name{dataset1.concept_name.en{dataset1.concept_name.en.definition{dataset1.concept_name.en.definition.content}.
- #process(document, reader) ⇒ Object
Methods included from Liquid::CustomFilters::Filters
#extract_grammar_info, #sanitize_references, #terminological_data, #values
Constructor Details
#initialize(config = {}) ⇒ DatasetPreprocessor
Search document for the following blocks
- :glossarist-dataset: dataset1:./dataset1;dataset2:./dataset2
This will load `glossarist` concepts from `./dataset1` path into
`dataset1` and concepts from `./dataset2` path into `dataset2`,
These can then be used anywhere in the document like
{{dataset1.concept_name.en.definition.content}}
- glossarist:render[dataset1, concept_name]
this will render the `concept_name` using the below format
==== concept term
alt:[if additional terms]
definition text
NOTE: if there is a note.
[example]
If there is an example.
[.source]
"\n- glossarist:import[dataset1]\n this will render all concepts in the `dataset1` using the above\n format\n" there is some source>>
50 51 52 53 54 55 56 57 58 |
# File 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb', line 50 def initialize(config = {}) super @config = config @datasets = {} @title_depth = { value: 2 } @rendered_bibliographies = {} @seen_glossarist = [] @context_names = [] end |
Instance Method Details
#process(document, reader) ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb', line 60 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) unless @seen_glossarist.empty? Asciidoctor::PreprocessorReader.new(document, processed_doc.to_s.split("\n")) end |