Class: Decidim::ContentParsers::NewlineParser
- Inherits:
-
BaseParser
- Object
- BaseParser
- Decidim::ContentParsers::NewlineParser
- Defined in:
- lib/decidim/content_parsers/newline_parser.rb
Overview
A parser that searches newline escape sequences in content.
The escape sequences ‘rn` and `r` will be replaced by `n`.
Constant Summary collapse
- ESCAPE_SEQUENCES =
["\r\n", "\r"].freeze
- REGEX =
Regexp.union(ESCAPE_SEQUENCES)
Constants inherited from BaseParser
Instance Attribute Summary
Attributes inherited from BaseParser
Instance Method Summary collapse
-
#rewrite ⇒ String
The content with the escape sequences replaced.
Methods inherited from BaseParser
Constructor Details
This class inherits a constructor from Decidim::ContentParsers::BaseParser
Instance Method Details
#rewrite ⇒ String
Returns the content with the escape sequences replaced.
15 16 17 |
# File 'lib/decidim/content_parsers/newline_parser.rb', line 15 def rewrite content.gsub(REGEX, "\n") end |