metanorma-plugin-lutaml 0.7.16 → 0.7.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/README.adoc +516 -278
 - data/lib/metanorma/plugin/lutaml/liquid_templates/_klass_table.liquid +4 -4
 - data/lib/metanorma/plugin/lutaml/lutaml_ea_diagram_block_macro.rb +50 -8
 - data/lib/metanorma/plugin/lutaml/lutaml_ea_xmi_base.rb +57 -5
 - data/lib/metanorma/plugin/lutaml/lutaml_preprocessor.rb +36 -130
 - data/lib/metanorma/plugin/lutaml/utils.rb +6 -1
 - data/lib/metanorma/plugin/lutaml/version.rb +1 -1
 - data/metanorma-plugin-lutaml.gemspec +2 -2
 - metadata +11 -12
 - data/lib/metanorma/plugin/lutaml/express_remarks_decorator.rb +0 -78
 
| 
         @@ -1,78 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            module Metanorma
         
     | 
| 
       2 
     | 
    
         
            -
              module Plugin
         
     | 
| 
       3 
     | 
    
         
            -
                module Lutaml
         
     | 
| 
       4 
     | 
    
         
            -
                  class ExpressRemarksDecorator
         
     | 
| 
       5 
     | 
    
         
            -
                    RELATIVE_PREFIX_MACRO_REGEXP = /^(link|image|video|audio|include)(:+)?(?![^\/:]+:\/\/|[A-Z]:\/|\/)([^:\[]+)(\[.*\])?$/.freeze
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
                    attr_reader :remark, :options
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
                    def self.call(remark, options)
         
     | 
| 
       10 
     | 
    
         
            -
                      new(remark, options).call
         
     | 
| 
       11 
     | 
    
         
            -
                    end
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
                    def initialize(remark, options)
         
     | 
| 
       14 
     | 
    
         
            -
                      @remark = remark
         
     | 
| 
       15 
     | 
    
         
            -
                      @options = options
         
     | 
| 
       16 
     | 
    
         
            -
                    end
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
                    def call
         
     | 
| 
       19 
     | 
    
         
            -
                      result = remark
         
     | 
| 
       20 
     | 
    
         
            -
                      if options["leveloffset"]
         
     | 
| 
       21 
     | 
    
         
            -
                        result = process_remark_offsets(result, options["leveloffset"].to_i)
         
     | 
| 
       22 
     | 
    
         
            -
                      end
         
     | 
| 
       23 
     | 
    
         
            -
                      if options["relative_path_prefix"]
         
     | 
| 
       24 
     | 
    
         
            -
                        result = update_relative_paths(result,
         
     | 
| 
       25 
     | 
    
         
            -
                                                       options["relative_path_prefix"])
         
     | 
| 
       26 
     | 
    
         
            -
                      end
         
     | 
| 
       27 
     | 
    
         
            -
                      result
         
     | 
| 
       28 
     | 
    
         
            -
                    end
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
                    private
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
                    def update_relative_paths(string, path_prefix)
         
     | 
| 
       33 
     | 
    
         
            -
                      string
         
     | 
| 
       34 
     | 
    
         
            -
                        .split("\n")
         
     | 
| 
       35 
     | 
    
         
            -
                        .map do |line|
         
     | 
| 
       36 
     | 
    
         
            -
                          if line.match?(RELATIVE_PREFIX_MACRO_REGEXP)
         
     | 
| 
       37 
     | 
    
         
            -
                            prefix_relative_paths(line, path_prefix)
         
     | 
| 
       38 
     | 
    
         
            -
                          else
         
     | 
| 
       39 
     | 
    
         
            -
                            line
         
     | 
| 
       40 
     | 
    
         
            -
                          end
         
     | 
| 
       41 
     | 
    
         
            -
                        end
         
     | 
| 
       42 
     | 
    
         
            -
                        .join("\n")
         
     | 
| 
       43 
     | 
    
         
            -
                    end
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
                    def prefix_relative_paths(line, path_prefix)
         
     | 
| 
       46 
     | 
    
         
            -
                      line.gsub(RELATIVE_PREFIX_MACRO_REGEXP) do |_match|
         
     | 
| 
       47 
     | 
    
         
            -
                        prefixed_path = File.join(path_prefix, $3.strip)
         
     | 
| 
       48 
     | 
    
         
            -
                        # When we are dealing with a relative path of a template:
         
     | 
| 
       49 
     | 
    
         
            -
                        # ../path/to/file we need to transform it into
         
     | 
| 
       50 
     | 
    
         
            -
                        # the absolute one because `image::` macro wont understand it other way
         
     | 
| 
       51 
     | 
    
         
            -
                        prefixed_path = File.absolute_path(prefixed_path) if prefixed_path.start_with?("../")
         
     | 
| 
       52 
     | 
    
         
            -
                        full_path = File.expand_path(prefixed_path)
         
     | 
| 
       53 
     | 
    
         
            -
                        "#{$1}#{$2}#{full_path}#{$4}"
         
     | 
| 
       54 
     | 
    
         
            -
                      end
         
     | 
| 
       55 
     | 
    
         
            -
                    end
         
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
                    def process_remark_offsets(string, offset)
         
     | 
| 
       58 
     | 
    
         
            -
                      string
         
     | 
| 
       59 
     | 
    
         
            -
                        .split("\n")
         
     | 
| 
       60 
     | 
    
         
            -
                        .map do |line|
         
     | 
| 
       61 
     | 
    
         
            -
                          if line.match?(/^=/)
         
     | 
| 
       62 
     | 
    
         
            -
                            set_string_offsets(line, offset)
         
     | 
| 
       63 
     | 
    
         
            -
                          else
         
     | 
| 
       64 
     | 
    
         
            -
                            line
         
     | 
| 
       65 
     | 
    
         
            -
                          end
         
     | 
| 
       66 
     | 
    
         
            -
                        end
         
     | 
| 
       67 
     | 
    
         
            -
                        .join("\n")
         
     | 
| 
       68 
     | 
    
         
            -
                    end
         
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
                    def set_string_offsets(string, offset)
         
     | 
| 
       71 
     | 
    
         
            -
                      return "#{'=' * offset}#{string}" if offset.positive?
         
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
                      string.gsub(/^={#{offset * -1}}/, "")
         
     | 
| 
       74 
     | 
    
         
            -
                    end
         
     | 
| 
       75 
     | 
    
         
            -
                  end
         
     | 
| 
       76 
     | 
    
         
            -
                end
         
     | 
| 
       77 
     | 
    
         
            -
              end
         
     | 
| 
       78 
     | 
    
         
            -
            end
         
     |