示例#1
0
 public function transform($text)
 {
     $parser = new MarkdownExtra();
     $stylesAdded = false;
     if (class_exists('Kadet\\Highlighter\\Language\\Language')) {
         $parser->code_block_content_func = function ($code, $language) use(&$stylesAdded) {
             if (!$stylesAdded) {
                 $this->pageStack->getPageResponse()->addCssFile('@Jarves/keylighter/default.scss');
                 $stylesAdded = true;
             }
             return Highlighter\highlight($code, Language::byName($language));
         };
     }
     return $parser->transform($text);
 }
示例#2
0
 public function testFunction()
 {
     $formatter = new HtmlFormatter();
     $language = new MockGreedyLanguage(['rules' => ['keyword' => new Rule(new SubStringMatcher('if'))]]);
     $this->assertEquals($formatter->format($language->parse('if test')), Highlighter\highlight('if test', $language, $formatter));
 }