module StripEmptyBlockHtmlHelper

Public Instance Methods

strip_empty_block_html(html) click to toggle source
# File strip_empty_block_html_helper.rb, line 2
def strip_empty_block_html(html)
  Nokogiri::HTML::DocumentFragment.parse(html).tap do |fragment|
    fragment.traverse do |node|
      if node.element? and node.description and node.description.block? and node.content.empty?
        node.remove
      end
    end
  end.to_html
end