normalize( input, doctype=nil, entity_filter=nil )
public
Escapes all possible entities
Show source
def Text::normalize( input, doctype=nil, entity_filter=nil )
copy = input
copy = copy.gsub( "&", "&" )
if doctype
doctype.entities.each_value do |entity|
copy = copy.gsub( entity.value,
"&#{entity.name};" ) if entity.value and
not( entity_filter and entity_filter.include?(entity) )
end
else
DocType::DEFAULT_ENTITIES.each_value do |entity|
copy = copy.gsub(entity.value, "&#{entity.name};" )
end
end
copy
end