Sha256: ad5861fa0cd651d63c283feae979f66db78d5516e353d430186212d5f1e15d8d

Contents?: true

Size: 474 Bytes

Versions: 6

Compression:

Stored size: 474 Bytes

Contents

module ImproveTypography
  module Processors
    class SingleQuotes < Processor
      REGEXP = /['’‘](.*?)['’‘](?!\w)/i

      def call
        replace_single_quotes
      end

      private

      def replace_single_quotes
        str.gsub(REGEXP, "#{single_quotes[0]}\\1#{single_quotes[1]}")
      end

      def single_quotes
        options.fetch(:single_quotes, I18n.t(:single_quotes, scope: %i(improve_typography), locale: locale))
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
improve_typography-0.1.11 lib/improve_typography/processors/single_quotes.rb
improve_typography-0.1.10 lib/improve_typography/processors/single_quotes.rb
improve_typography-0.1.9 lib/improve_typography/processors/single_quotes.rb
improve_typography-0.1.8 lib/improve_typography/processors/single_quotes.rb
improve_typography-0.1.7 lib/improve_typography/processors/single_quotes.rb
improve_typography-0.1.6 lib/improve_typography/processors/single_quotes.rb