Class: Metanorma::Plugin::Lutaml::LutamlPreprocessor
- Inherits:
-
BasePreprocessor
- Object
- Asciidoctor::Extensions::Preprocessor
- BasePreprocessor
- Metanorma::Plugin::Lutaml::LutamlPreprocessor
- Defined in:
- lib/metanorma/plugin/lutaml/lutaml_preprocessor.rb
Overview
Preprocessor for EXPRESS schema formats (lutaml, lutaml_express, lutaml_express_liquid). Parses EXPRESS files via the lutaml/expressir gems, decorates remarks with relative path resolution, and renders Liquid templates with the EXPRESS-specific Liquid environment.
Constant Summary collapse
- 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
Constants inherited from BasePreprocessor
BasePreprocessor::FILE_SYSTEM_PATTERNS
Constants included from Utils
Instance Method Summary collapse
- #decorate_remark_items(model, options) ⇒ Object
- #traversable_model_element?(child) ⇒ Boolean
- #update_remarks(model, options) ⇒ Object
Methods inherited from BasePreprocessor
Methods included from Utils
create_liquid_environment, error_signature, load_express_from_folder, load_express_from_index, load_express_repo_from_cache, load_express_repo_from_path, load_express_repositories, notify_render_errors, parse_document_express_indexes, processed_lines, relative_file_path, render_liquid_string, save_express_repo_to_cache
Instance Method Details
#decorate_remark_items(model, options) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/metanorma/plugin/lutaml/lutaml_preprocessor.rb', line 41 def decorate_remark_items(model, ) return unless model.is_a?(Expressir::Model::HasRemarkItems) model.remark_items&.each do |ri| ri.remarks = decorate_remarks(, ri.remarks) end end |
#traversable_model_element?(child) ⇒ Boolean
36 37 38 39 |
# File 'lib/metanorma/plugin/lutaml/lutaml_preprocessor.rb', line 36 def traversable_model_element?(child) child.is_a?(Expressir::Model::ModelElement) && !child.is_a?(Expressir::Model::Declarations::RemarkItem) end |
#update_remarks(model, options) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/metanorma/plugin/lutaml/lutaml_preprocessor.rb', line 25 def update_remarks(model, ) model.remarks = decorate_remarks(, model.remarks) decorate_remark_items(model, ) model.children.each do |child| next unless traversable_model_element?(child) update_remarks(child, ) end end |