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