Sha256: c0436225a51995ea960956ec17851d5df3380c79a0bd02740ff505f4f948c473

Contents?: true

Size: 1016 Bytes

Versions: 13

Compression:

Stored size: 1016 Bytes

Contents

# frozen_string_literal: true

module Stepmod
  module Utils
    module Converters
      class Dl < Stepmod::Utils::Converters::Base
        def convert(node, state = {})
          cleaned_node = cleanup_trash_tags(node.clone)
          treat_children(cleaned_node, state)
        end

        private

        # https://github.com/metanorma/stepmod-utils/issues/48#issuecomment-784000377
        # For simplicity reasons and so that we don't depend on the CVS repository's updates, we directly converting:
        # <dt></dt><dd>a3ma &#160; : &#160; annotated 3d model assembly</dd> into a3ma:: annotated 3d model assembly
        def cleanup_trash_tags(node)
          inner_content = node.inner_html
          inner_content
            .gsub!(/<dt><\/dt>\s*?<dd>(.+?) &#xA0; : &#xA0; (.+?)<\/dd>/) do
              "<dt>#{$1}</dt><dd>#{$2}</dd>"
            end
          node.inner_html = inner_content
          node
        end

        ReverseAdoc::Converters.register :dl, Dl.new
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
stepmod-utils-0.6.6 lib/stepmod/utils/converters/dl.rb
stepmod-utils-0.6.5 lib/stepmod/utils/converters/dl.rb
stepmod-utils-0.6.3 lib/stepmod/utils/converters/dl.rb
stepmod-utils-0.6.2 lib/stepmod/utils/converters/dl.rb
stepmod-utils-0.6.1 lib/stepmod/utils/converters/dl.rb
stepmod-utils-0.6.0 lib/stepmod/utils/converters/dl.rb
stepmod-utils-0.5.0 lib/stepmod/utils/converters/dl.rb
stepmod-utils-0.4.14 lib/stepmod/utils/converters/dl.rb
stepmod-utils-0.4.13 lib/stepmod/utils/converters/dl.rb
stepmod-utils-0.4.12 lib/stepmod/utils/converters/dl.rb
stepmod-utils-0.4.11 lib/stepmod/utils/converters/dl.rb
stepmod-utils-0.4.10 lib/stepmod/utils/converters/dl.rb
stepmod-utils-0.4.9 lib/stepmod/utils/converters/dl.rb