Module: Govspeak::BlockquoteExtraQuoteRemover

Defined in:
lib/govspeak/blockquote_extra_quote_remover.rb

Constant Summary collapse

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

Class Method Summary collapse

Class Method Details

.remove(source) ⇒ Object

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



14
15
16
17
18
19
# File 'lib/govspeak/blockquote_extra_quote_remover.rb', line 14

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