Esempio n. 1
0
 public static function render($src, $opt = null)
 {
     if ($opt === null) {
         $opt = array();
     }
     $opt = array_merge(self::$defaults, $opt);
     $tokens = Lexer::doLex($src, $opt);
     if (isset($opt['highlight']) && count($tokens['tokens']) > 0) {
         foreach ($tokens as $i => $token) {
             if ($token['type'] !== 'code') {
                 continue;
             }
             $ret = $opt['highlight']($token['text'], $token['lang']);
             if ($ret === null || $ret === $token['text']) {
                 continue;
             }
             $tokens[$i]['text'] = $ret;
             $tokens[$i]['escaped'] = true;
         }
     }
     $out = Parser::doParse($tokens['tokens'], $tokens['tokens_links'], $opt);
     return $out;
 }
Esempio n. 2
0
 public static function doLex($src, $options)
 {
     $lexer = new Lexer($options);
     return $lexer->lex($src);
 }