Sha256: 826ed152b1ca368365a5b2e9566fcfbd15015c43d3397ca05473c428d344729d

Contents?: true

Size: 544 Bytes

Versions: 10

Compression:

Stored size: 544 Bytes

Contents

require 'sanitize'

class Govspeak::HtmlSanitizer
  def initialize(dirty_html)
    @dirty_html = dirty_html
  end

  def sanitize
    Sanitize.clean(@dirty_html, sanitize_config)
  end

  def sanitize_without_images
    config = sanitize_config
    config[:elements].delete('img')
    Sanitize.clean(@dirty_html, config)
  end

  def sanitize_config
    config = Sanitize::Config::RELAXED.dup
    config[:attributes][:all].push("id", "class")
    config[:attributes]["a"].push("rel")
    config[:elements].push("div", "hr")
    config
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
govspeak-1.6.2 lib/govspeak/html_sanitizer.rb
govspeak-1.6.1 lib/govspeak/html_sanitizer.rb
govspeak-1.6.0 lib/govspeak/html_sanitizer.rb
govspeak-1.5.4 lib/govspeak/html_sanitizer.rb
govspeak-1.5.3 lib/govspeak/html_sanitizer.rb
govspeak-1.5.2 lib/govspeak/html_sanitizer.rb
govspeak-1.5.1 lib/govspeak/html_sanitizer.rb
govspeak-1.5.0 lib/govspeak/html_sanitizer.rb
govspeak-1.4.0 lib/govspeak/html_sanitizer.rb
govspeak-1.3.0 lib/govspeak/html_sanitizer.rb