# File lib/rubypants.rb, line 235 def educate(str, patt, repl, prevent_breaks) patt = /(?<spaces>[[:space:]]*)#{patt}/ str.gsub(patt) do spaces = if prevent_breaks && $~['spaces'].length > 0 entity(:non_breaking_space) # * $~['spaces'].length elsif prevent_breaks entity(:word_joiner) else $~['spaces'] end spaces + repl end end