Sha256: c7e34c8a786f0284e7e5dceb8d5756ceee1c62de879ca2837987b2278ba895b8

Contents?: true

Size: 562 Bytes

Versions: 64

Compression:

Stored size: 562 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module ContentParsers
    # A parser that searches newline escape sequences in content.
    #
    # The escape sequences `\r\n` and `\r` will be replaced by `\n`.
    #
    # @see BaseParser Examples of how to use a content parser
    class NewlineParser < BaseParser
      ESCAPE_SEQUENCES = ["\r\n", "\r"].freeze
      REGEX = Regexp.union(ESCAPE_SEQUENCES)

      # @return [String] the content with the escape sequences replaced.
      def rewrite
        content.gsub(REGEX, "\n")
      end
    end
  end
end

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
decidim-core-0.29.1 lib/decidim/content_parsers/newline_parser.rb
decidim-core-0.28.4 lib/decidim/content_parsers/newline_parser.rb
decidim-core-0.27.9 lib/decidim/content_parsers/newline_parser.rb
decidim-core-0.29.0 lib/decidim/content_parsers/newline_parser.rb
decidim-core-0.28.3 lib/decidim/content_parsers/newline_parser.rb
decidim-core-0.27.8 lib/decidim/content_parsers/newline_parser.rb
decidim-core-0.29.0.rc4 lib/decidim/content_parsers/newline_parser.rb
decidim-core-0.29.0.rc3 lib/decidim/content_parsers/newline_parser.rb
decidim-core-0.29.0.rc2 lib/decidim/content_parsers/newline_parser.rb
decidim-core-0.29.0.rc1 lib/decidim/content_parsers/newline_parser.rb
decidim-core-0.28.2 lib/decidim/content_parsers/newline_parser.rb
decidim-core-0.27.7 lib/decidim/content_parsers/newline_parser.rb
decidim-core-0.28.1 lib/decidim/content_parsers/newline_parser.rb
decidim-core-0.27.6 lib/decidim/content_parsers/newline_parser.rb
decidim-core-0.26.10 lib/decidim/content_parsers/newline_parser.rb
decidim-core-0.26.9 lib/decidim/content_parsers/newline_parser.rb
decidim-core-0.28.0 lib/decidim/content_parsers/newline_parser.rb
decidim-core-0.27.5 lib/decidim/content_parsers/newline_parser.rb
decidim-core-0.28.0.rc5 lib/decidim/content_parsers/newline_parser.rb
decidim-core-0.28.0.rc4 lib/decidim/content_parsers/newline_parser.rb