Module: Sterile

Defined in:
lib/sterile/sterile.rb

Class Method Summary collapse

Class Method Details

.old_smart_format_rulesObject



3
# File 'lib/sterile/sterile.rb', line 3

alias_method :old_smart_format_rules, :smart_format_rules

.smart_format_rulesObject

# what would replace the Sterile rules with more broadly applicable Zs

  [/(\p{Zs}|\A|"|\(|\[)'/, "\\1‘"],
  [/(\S)'([^\'\p{Zs}])/, "\\1’\\2"],
  [/(\p{Zs}|\A|\(|\[)"(?!\s)/, "\\1“\\2"],
  [/"(\p{Zs}|\S|\Z)/, "”\\1"],
  [/'([\p{Zs}.]|\Z)/, "’\\1"],
] + old_smart_format_rules


13
14
15
16
17
18
19
20
# File 'lib/sterile/sterile.rb', line 13

def smart_format_rules
  [
    [/(\S)'([^\'\p{Zs}])/, "\\1’\\2"],
    [/(\p{Zs})"(?!\s)/, "\\1“\\2"],
    [/"(\p{Zs})/, "”\\1"],
    [/'([\p{Zs}.])/, "’\\1"],
  ] + old_smart_format_rules
end