Sha256: 6c94321f93f0f30dd3fbc51101d006df04fc41885c001dd82dc22089bfec05c6

Contents?: true

Size: 629 Bytes

Versions: 55

Compression:

Stored size: 629 Bytes

Contents

module Govspeak
  module BlockquoteExtraQuoteRemover
    QUOTES = '["\u201C\u201D\u201E\u201F\u2033\u2036]+'.freeze
    WHITESPACE = '[^\S\r\n]*'.freeze

    # used to remove quotes from a markdown blockquote, as these will be inserted
    # as part of the rendering
    #
    # for example:
    # > "test"
    #
    # will be formatted to:
    # > test
    def self.remove(source)
      return if source.nil?

      source.gsub(/^>#{WHITESPACE}#{QUOTES}#{WHITESPACE}(.+?)$/, '> \1') # prefixed with a quote
            .gsub(/^>(.+?)#{WHITESPACE}#{QUOTES}#{WHITESPACE}(\r?)$/, '>\1\2') # suffixed with a quote
    end
  end
end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
govspeak-8.7.0 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-8.6.1 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-8.6.0 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-8.5.1 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-8.5.0 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-8.4.1 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-8.4.0 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-8.3.4 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-8.3.3 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-8.3.2 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-8.3.1 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-8.3.0 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-8.2.1 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-8.2.0 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-8.1.0 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-8.0.1 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-8.0.0 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-7.1.1 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-7.1.0 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-7.0.2 lib/govspeak/blockquote_extra_quote_remover.rb