* Initial automatic cleanup with rubocop * Fix syntax error introduced by rubocop * Cleanup seeds file * Cleanup lib folder * Exclude bin folder because it contains auto generated files * Make Rubocop a little bit more chatty * Block length should not include comments in the count * Cleanup config folder * Cleanup specs * Updated Rubocop version and generated a todo file * Fix broken ArticlesApi spec * Fix tests * Restored rubocop pre-commit hook
24 lines
561 B
Ruby
24 lines
561 B
Ruby
class HtmlCleaner
|
|
def clean_html(html)
|
|
doc = Nokogiri::HTML(html)
|
|
# Remove Medium tracking pixel
|
|
doc.css("img").each do |img|
|
|
if img.attr("src") && (img.attr("src").include? "medium.com/_/stat")
|
|
img.remove
|
|
end
|
|
end
|
|
# Remove Medium catch phrase
|
|
doc.css("p").each do |p|
|
|
if p.text.include? "where people are continuing the conversation by highlighting"
|
|
p.remove
|
|
end
|
|
end
|
|
|
|
doc.css("figure").each do |el|
|
|
el.name = "p"
|
|
end
|
|
|
|
doc.xpath("//@class").remove
|
|
doc.to_html
|
|
end
|
|
end
|