Class: Decidim::ContentParsers::NewlineParser

Inherits:
BaseParser
  • Object
show all
Defined in:
decidim-core/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

BaseParser::Metadata

Instance Attribute Summary

Attributes inherited from BaseParser

#content, #context

Instance Method Summary collapse

Methods inherited from BaseParser

#initialize, #metadata

Methods included from Decidim::ContentProcessor::Common

#html_content?, #html_fragment

Constructor Details

This class inherits a constructor from Decidim::ContentParsers::BaseParser

Instance Method Details

#rewriteString

Returns the content with the escape sequences replaced.

Returns:

  • (String)

    the content with the escape sequences replaced.



15
16
17
# File 'decidim-core/lib/decidim/content_parsers/newline_parser.rb', line 15

def rewrite
  content.gsub(REGEX, "\n")
end