joshhepworth/titlify

View on GitHub
lib/titlify/data/smart_format_rules.rb

Summary

Maintainability
A
1 hr
Test Coverage
# encoding: UTF-8

module Titlify
  class Data
    def self.smart_format_rules
      [
        ["'tain't", "’tain’t"],
        ["'twere", "’twere"],
        ["'twas", "’twas"],
        ["'tis", "’tis"],
        ["'twill", "’twill"],
        ["'til", "’til"],
        ["'bout", "’bout"],
        ["'nuff", "’nuff"],
        ["'round", "’round"],
        ["'cause", "’cause"],
        ["'cos", "’cos"],
        ["i'm", "i’m"],
        ['--"', "—”"],
        ["--'", "—’"],
        ["--", "—"],
        ["...", "…"],
        ["(tm)", "™"],
        ["(TM)", "™"],
        ["(c)", "©"],
        ["(r)", "®"],
        ["(R)", "®"],
        [/s\'([^a-zA-Z0-9])/, "s’\\1"],
        [/"([:;])/, "”\\1"],
        [/\'s$/, "’s"],
        [/\'(\d\d(?:’|\')?s)/, "’\\1"],
        [/(\s|\A|"|\(|\[)\'/, "\\1‘"],
        [/(\d+)"/, "\\1′"],
        [/(\d+)\'/, "\\1″"],
        [/(\S)\'([^\'\s])/, "\\1’\\2"],
        [/(\s|\A|\(|\[)"(?!\s)/, "\\1“\\2"],
        [/"(\s|\S|\Z)/, "”\\1"],
        [/\'([\s.]|\Z)/, "’\\1"],
        [/(\d+)x(\d+)/, "\\1×\\2"],
        [/([a-z])'(t|d|s|ll|re|ve)(\b)/i, "\\1’\\2\\3"]
      ]
    end
  end
end