Class: Loofah::Scrubbers::NewlineBlockElements
- Inherits:
-
Loofah::Scrubber
- Object
- Loofah::Scrubber
- Loofah::Scrubbers::NewlineBlockElements
- 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
Instance Method Summary collapse
-
#initialize ⇒ NewlineBlockElements
constructor
:nodoc:.
- #scrub(node) ⇒ Object
Methods inherited from Loofah::Scrubber
Constructor Details
#initialize ⇒ NewlineBlockElements
:nodoc:
306 307 308 |
# File 'lib/loofah/scrubbers.rb', line 306 def initialize # rubocop:disable Lint/MissingSuper @direction = :bottom_up end |
Instance Method Details
#scrub(node) ⇒ Object
310 311 312 313 314 315 316 317 318 319 320 |
# File 'lib/loofah/scrubbers.rb', line 310 def scrub(node) return CONTINUE unless Loofah::Elements::LINEBREAKERS.include?(node.name) replacement = if Loofah::Elements::INLINE_LINE_BREAK.include?(node.name) "\n" else "\n#{node.content}\n" end node.add_next_sibling(Nokogiri::XML::Text.new(replacement, node.document)) node.remove end |