Esempio n. 1
0
 /**
  * Removes indentation
  *
  * @param string $text The markdown text
  * @return mixed
  */
 protected function transform($text)
 {
     $firstLine = explode("\n", $text, 1);
     $firstLine = Str::toSpaces($firstLine[0], 4);
     preg_match('/([\\s]*).*/', $firstLine, $firstLineSpacesMatches);
     if (isset($firstLineSpacesMatches[1])) {
         $spaceMatcher = "";
         for ($i = 0; $i < strlen($firstLineSpacesMatches[1]); $i++) {
             $spaceMatcher .= "\\s";
         }
         $spaceMatcher = '/^' . $spaceMatcher . '(.*)/m';
         $newText = preg_replace($spaceMatcher, '$1', $text);
         return $newText;
     }
     return $text;
 }