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.99.1 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.99.0 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.98.1 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.98.0 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.96.0 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.95.1 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.95.0 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.94.2 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.94.1 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.94.0 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.93.1 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.93.0 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.92.0 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.91.4 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.91.3 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.91.2 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.91.1 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.91.0 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.90.0 lib/cocina/models/mapping/escape_html.rb
cocina-models-0.89.1 lib/cocina/models/mapping/escape_html.rb