class ImproveTypography::Processors::Nbsp
Public Instance Methods
call()
click to toggle source
# File lib/improve_typography/processors/nbsp.rb, line 4 def call return str unless str.match?(/(\A|\s+)(\S|\d+)([\.?!]?)(\s+|\z)/) str .gsub(/(\s+)(\S|\d+|\S\.)(\s+)(\S)/, '\1\2 \4') # in the middle of string .gsub(/\A(\w|\d+|\w\.)(\s+)(\S)/, '\1 \3') # at the beginning of string .gsub(/([^\S\n])(\S|\d+|\S\.)(\z|[\.?!]\z|[\.?!]\s)/, ' \2\3') # at the end of string!! .gsub(/(\A|\s+)(©)(\s+)(\d+)/, '\1\2 \4') .gsub(/(\A|\s+)(No\.|Vol\.)(\s+)(\d+)/, '\1\2 \3') end