Exemplo n.º 1
0
 /**
  * Preprocess the text.
  *
  * This unifies line endings and replaces tabs by spaces.
  *
  * @param Text $text
  * @return void
  */
 protected function prepare(Text $text)
 {
     // Unify line endings
     $text->replaceString("\r\n", "\n");
     $text->replaceString("\r", "\n");
     // Replace tabs by spaces
     $text->replace('/(.*?)\\t/', function (Text $whole, Text $string) {
         $tabWidth = 4;
         return $string . str_repeat(' ', $tabWidth - $string->getLength() % $tabWidth);
     });
 }
Exemplo n.º 2
0
 public function handleBackslashes(Text $content)
 {
     $content->replaceString(['\\\\', '\\!', '\\"', '\\#', '\\$', '\\%', '\\&', '\\\'', '\\(', '\\)', '\\*', '\\+', '\\,', '\\-', '\\.', '\\/', '\\:', '\\;', '\\<', '\\=', '\\>', '\\?', '\\@', '\\[', '\\]', '\\^', '\\_', '\\`', '\\{', '\\|', '\\}', '\\~'], ['\\', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '@', '[', ']', '^', '_', '`', '{', '|', '}', '~']);
 }