Sanitize::Policy::Text
Inherits Sanitize::Policy < Reference < Object
Reduces an HTML tree to the content of its text nodes. It renders a plain text result, similar to copying HTML content rendered by a browser to a text editor. HTML special characters are escaped.
policy = Sanitize::Policy::Text.new
policy.process(%(foo <strong><a href="bar">bar</a>!</strong>)) # => "foo bar!"
policy.process(%(<p>foo</p><p>bar</p>)) # => "foo bar"
policy.block_whitespace = "\n"
policy.process(%(<p>foo</p><p>bar</p>)) # => "foo\nbar"
Instance methods
Receives the element name and attributes of an opening tag and returns the transformed element name (usually the same as the input name).
attributes are transformed directly in place.
Special return values:
Processor::CONTINUE: Tells the processor to strip the current tag but continue traversing its children.Processor::CONTINUE: Tells the processor to skip the current tag and its children completely and move to the next sibling.