Module: Models::HtmlContent

Extended by:
ActiveSupport::Concern
Included in:
Coupon
Defined in:
app/concerns/models/html_content.rb

Instance Method Summary collapse

Instance Method Details

#sanitize_html_fragment(html) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/concerns/models/html_content.rb', line 8

def sanitize_html_fragment(html)
  return unless html.present?
  page = Nokogiri::HTML(html)
  h = page.at('body')&.inner_html.presence
  sd = Seo::DeparameterizeLinks.new
  ld = Seo::HtmlLinkSanitizer.new
  imgf = Seo::ImageMissingSizeFiller.new
  h = ld.process(h).html_out
  h = sd.process(h).html_out
  h = imgf.process(h).html_out
  h
end