Class: Cocina::Models::Mapping::EscapeHtml
- Inherits:
-
Object
- Object
- Cocina::Models::Mapping::EscapeHtml
- Defined in:
- lib/cocina/models/mapping/escape_html.rb
Overview
Escaps HTML entities as CDATA for MODS since HTML is not permitted in MODS
Class Method Summary collapse
Class Method Details
.with_cdata(data, builder) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/cocina/models/mapping/escape_html.rb', line 10 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 |