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-7.0.1 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-7.0.0 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-6.8.4 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-6.8.3 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-6.8.2 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-6.8.1 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-6.8.0 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-6.7.8 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-6.7.7 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-6.7.6 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-6.7.5 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-6.7.4 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-6.7.3 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-6.7.2 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-6.7.1 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-6.7.0 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-6.6.0 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-6.5.11 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-6.5.10 lib/govspeak/blockquote_extra_quote_remover.rb
govspeak-6.5.9 lib/govspeak/blockquote_extra_quote_remover.rb