Class: Loofah::Scrubbers::NewlineBlockElements

Inherits:
Loofah::Scrubber show all
Defined in:
lib/loofah/scrubbers.rb

Overview

This class probably isn’t useful publicly, but is used for #to_text’s current implemention

Constant Summary

Constants inherited from Loofah::Scrubber

Loofah::Scrubber::CONTINUE, Loofah::Scrubber::STOP

Instance Attribute Summary

Attributes inherited from Loofah::Scrubber

#block, #direction

Instance Method Summary collapse

Methods inherited from Loofah::Scrubber

#append_attribute, #traverse

Constructor Details

#initializeNewlineBlockElements

:nodoc:



238
239
240
# File 'lib/loofah/scrubbers.rb', line 238

def initialize
  @direction = :bottom_up
end

Instance Method Details

#scrub(node) ⇒ Object



242
243
244
245
246
# File 'lib/loofah/scrubbers.rb', line 242

def scrub(node)
  return CONTINUE unless Loofah::Elements::BLOCK_LEVEL.include?(node.name)
  node.add_next_sibling Nokogiri::XML::Text.new("\n#{node.content}\n", node.document)
  node.remove
end