* Clarify uncommunicative variables in labor classes Single letter variable names are largely a question of preference, in some cases I think that convention mitigates the opaque nature of single letter variable names (e.g., e for error, i for index, etc). However, in some cases they can be unclear and there isn't much reason to use single letter variables unless for some reason character length is really important. In this case, I would prefer clarity in variable names over brevity of code so I've used Reek to identify short variable names and I'm changing them. It's pretty boring, but hopefully incremental code love changes like this one add up and improve readability and accessibility for those interested in reading this codebase. * Remove commented code from 2 years ago * Clarify uncommunicative naming in services classes There is some context for this change in 6b81880f * Clarify uncommunicative naming in models There is some context for this change in 6b81880f * Clarify uncommunicative naming in liquid_tags There is some context for this change in 6b81880f
20 lines
549 B
Ruby
20 lines
549 B
Ruby
class HtmlCleaner
|
|
def clean_html(html)
|
|
doc = Nokogiri::HTML(html)
|
|
# Remove Medium tracking pixel
|
|
doc.css("img").each do |img|
|
|
img.remove if img.attr("src") && (img.attr("src").include? "medium.com/_/stat")
|
|
end
|
|
# Remove Medium catch phrase
|
|
doc.css("p").each do |paragraph|
|
|
paragraph.remove if paragraph.text.include? "where people are continuing the conversation by highlighting"
|
|
end
|
|
|
|
doc.css("figure").each do |el|
|
|
el.name = "p"
|
|
end
|
|
|
|
doc.xpath("//@class").remove
|
|
doc.to_html
|
|
end
|
|
end
|