Method: IsoDoc::Function::Utils#cleanup_entities

Defined in:
lib/isodoc/function/utils.rb

#cleanup_entities(text, is_xml: true) ⇒ Object



230
231
232
233
234
235
236
237
238
239
240
# File 'lib/isodoc/function/utils.rb', line 230

def cleanup_entities(text, is_xml: true)
  c = HTMLEntities.new
  if is_xml
    text.split(/([<>])/).each_slice(4).map do |a|
      a[0] = c.encode(c.decode(a[0]), :hexadecimal)
      a
    end.join
  else
    c.encode(c.decode(text), :hexadecimal)
  end
end