Skip to content
Snippets Groups Projects
Unverified Commit 678cdb14 authored by Sébastien Gaya's avatar Sébastien Gaya
Browse files

wip custom sanitize configuration

parent 6677717b
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,16 @@ class Wordpress
attr_reader :domain
def self.clean(html)
fragment = Sanitize.fragment(html, Sanitize::Config::RELAXED)
fragment = Sanitize.fragment(html, Sanitize::Config.merge(Sanitize::Config::RELAXED,
attributes: Sanitize::Config::RELAXED[:attributes].merge({
all: Sanitize::Config::RELAXED[:attributes][:all].dup.delete('class'),
'a' => Sanitize::Config::RELAXED[:attributes]['a'].dup.delete('rel')
}),
elements: Set.new(Sanitize::Config::RELAXED[:elements]).delete('div'),
whitespace_elements: {
'div' => { :before => "", :after => "" }
}
))
fragment = Nokogiri::HTML5.fragment(fragment)
if fragment.css('h1').any?
# h1 => h2 ; h2 => h3 ; ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment