Module: CrazyHarry::Default
- Included in:
- Base
- Defined in:
- lib/crazy_harry/default.rb
Constant Summary collapse
- TARGET_ELEMENTS =
['b'].to_set
Instance Method Summary collapse
Instance Method Details
#convert_br_to_p! ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/crazy_harry/default.rb', line 17 def convert_br_to_p! fragment.xpath('br/following-sibling::text()|br/preceding-sibling::text()').each do |node| node.replace(Nokogiri.make("<p>#{node.to_html.strip}</p>")) unless node.content =~ /\A\s*\z/ end fragment.scrub!(scrub_tag('br')) end |
#dedupe! ⇒ Object
12 13 14 15 |
# File 'lib/crazy_harry/default.rb', line 12 def dedupe! self.fragment = Loofah.fragment(html_with_duplicates_removed_from_the_bottom_up) self end |
#no_blanks! ⇒ Object
6 7 8 9 10 |
# File 'lib/crazy_harry/default.rb', line 6 def no_blanks! self.steps << remove_blank_elements run! self end |