Class: Metanorma::Plugin::Glossarist::DatasetPreprocessor
- Inherits:
-
Asciidoctor::Extensions::Preprocessor
- Object
- Asciidoctor::Extensions::Preprocessor
- Metanorma::Plugin::Glossarist::DatasetPreprocessor
- 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,(.+?),(.+?)\]/.freeze
- GLOSSARIST_FILTER_BLOCK_REGEX =
rubocop:disable Layout/LineLength
/^\[glossarist,(.+?),(filter=.+?),(.+?)\]/.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
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
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]
<<If there is some source>>
- glossarist:import[dataset1]
this will render all concepts in the `dataset1` using the above
format
48 49 50 51 52 53 54 55 |
# File 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb', line 48 def initialize(config = {}) super @config = config @datasets = {} @title_depth = { value: 2 } @rendered_bibliographies = {} @seen_glossarist = [] end |
Instance Method Details
#process(document, reader) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb', line 57 def process(document, reader) input_lines = reader.lines.to_enum file_system = ::Liquid::LocalFileSystem.new( relative_file_path(document, ""), ) @config[:file_system] = file_system 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 |