Sha256: 37432479a813536f168cf848e7dcbdac9c7bf640cf2efaf361e4db233a0c5bd2

Contents?: true

Size: 581 Bytes

Versions: 34

Compression:

Stored size: 581 Bytes

Contents

# frozen_string_literal: true

module Cocina
  module Models
    module Mapping
      # Escaps HTML entities as CDATA for MODS since HTML is not permitted in MODS
      class EscapeHtml
        # @param [String] data
        # @param [Nokogiri::XML::Builder]
        def self.with_cdata(data, builder)
          tokens = data.split(%r{(</?(?:i|cite)>)})
          tokens.map do |token|
            if /\A<.+>\z/.match? token
              builder.cdata(token)
            else
              builder.text(token)
            end
          end
        end
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
cocina-models-0.89.0 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.88.0 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.87.1 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.87.0 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.86.0 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.85.0 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.84.5 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.84.4 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.84.3 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.84.2 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.84.1 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.84.0 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.83.0 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.82.0 lib/cocina/models/mapping/escape_html.rb