Module: Models::HtmlContent

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

Overview

ActiveSupport::Concern mixin: html content.

Instance Method Summary collapse

Instance Method Details

#sanitize_html_fragment(html) ⇒ Object



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

def sanitize_html_fragment(html)
  return if html.blank?

  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
  imgf.process(h).html_out
end