Class: Metanorma::Plugin::Lutaml::LutamlPreprocessor
- Inherits:
-
Asciidoctor::Extensions::Preprocessor
- Object
- Asciidoctor::Extensions::Preprocessor
- Metanorma::Plugin::Lutaml::LutamlPreprocessor
- Defined in:
- lib/metanorma/plugin/lutaml/lutaml_preprocessor.rb
Overview
Class for processing Lutaml files
Constant Summary collapse
- REMARKS_ATTRIBUTE =
"remarks"
- EXPRESS_PREPROCESSOR_REGEX =
%r{ ^ # Start of line \[ # Opening bracket (?:\blutaml\b| # Match lutaml or \blutaml_express\b| # lutaml_express or \blutaml_express_liquid\b) # lutaml_express_liquid , # Comma separator (?<index_names>[^,]+)? # Optional index names ,? # Optional comma (?<context_name>[^,]+)? # Optional context name (?<options>,.*)? # Optional options \] # Closing bracket }x.freeze
Instance Method Summary collapse
-
#process(document, reader) ⇒ Object
rubocop:disable Metrics/MethodLength.
Instance Method Details
#process(document, reader) ⇒ Object
rubocop:disable Metrics/MethodLength
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/metanorma/plugin/lutaml/lutaml_preprocessor.rb', line 31 def process(document, reader) # rubocop:disable Metrics/MethodLength r = Asciidoctor::PreprocessorNoIfdefsReader.new(document, reader.lines) input_lines = r.readlines.to_enum has_lutaml_liquid = input_lines.any? { |line| lutaml_liquid?(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_liquid Asciidoctor::PreprocessorNoIfdefsReader.new(document, result_content) end |