Class: AbAdmin::Utils::Sanitizer
- Includes:
- ActionView::Helpers::SanitizeHelper
- Defined in:
- lib/ab_admin/utils.rb
Instance Method Summary collapse
Instance Method Details
#normalize_html(raw_html) ⇒ Object
86 87 88 89 90 91 92 93 |
# File 'lib/ab_admin/utils.rb', line 86 def normalize_html(raw_html) return '' if raw_html.blank? html = sanitize(raw_html.gsub(/<!--(.*?)-->[\n]?/m, '')) doc = Nokogiri::HTML.fragment(html) #doc.xpath('comment()').each { |c| c.remove } doc.search('div').each { |el| el.name = 'p' } doc.to_html end |