Esempio n. 1
0
 /**
  * Outputs or returns a syntax highlighted version of the given PHP code using
  * the colors defined in the included stylesheet
  *
  * @param string $source The PHP code to be highlighted. This should include the opening tag
  * @param bool $return optional Set this parameter to TRUE to make this function return the highlighted code
  * @return string|void
  *
  * @access public
  * @since 1.0.0
  * @static
  */
 public static function highlight($source, $return = FALSE, $options = 0)
 {
     $p = new PHPLighter($source, $options);
     $str = $p->parse();
     if ($return) {
         return $str;
     }
     echo $str;
 }
 public static function indentPhp($code)
 {
     $r = \PHPLighter::highlight($code, true, \PHPLighter::NO_LINKIFY_LINKS | \PHPLighter::NO_LINKIFY_EMAILS);
     $r = nl2br($r);
     $r = preg_replace('/^(<pre class="pretty-php">)/', '<zz class="pretty-php">', $r);
     $r = preg_replace('/(<\\/pre>)$/', '</zz>', $r);
     $r = preg_replace('/[\\r\\n]/', '', $r);
     return $r;
 }