Sha256: 6ee97cf4dfe3440d976eca189fd34d46707d5727df44065a2e1900f3c564f355

Contents?: true

Size: 929 Bytes

Versions: 2

Compression:

Stored size: 929 Bytes

Contents

# frozen_string_literal: true

module Stepmod
  module Utils
    module Converters
      class ModuleRef < ReverseAdoc::Converters::Base
        def convert(node, _state = {})
          ref = node["linkend"]
          # #23:
          # In this case when we see this:

          # <module_ref linkend="product_as_individual:3_definition">individual products</module_ref>
          # We take the text value of the element and convert to this:

          # {{individual products}}

          ref = node.text.strip
          if !ref.empty?
            " {{#{normalized_ref(ref)}}} "
          elsif
            ref = node["linkend"].split(":").first
            " *#{ref}*"
          end
        end

        private

        def normalized_ref(ref)
          return unless ref || ref.empty?

          ref.squeeze(" ").strip
        end
      end
      ReverseAdoc::Converters.register :module_ref, ModuleRef.new
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stepmod-utils-0.3.8 lib/stepmod/utils/converters/module_ref.rb
stepmod-utils-0.3.7 lib/stepmod/utils/converters/module_ref.rb