コード例 #1
0
 protected function completeFencedCode($Block)
 {
     // If we have set a highlighter
     if (empty($this->highlighter)) {
         return parent::completeFencedCode($Block);
     }
     // Identify the code language
     $class = $Block['element']['text']['attributes']['class'];
     $language = !empty($class) ? preg_replace('/^language\\-/i', '', $class) : null;
     if (empty($language)) {
         return $Block;
     }
     // Proceed with a highlighter
     $output = $this->highlighter->highlight($Block['element']['text']['text'], $language);
     $Block['element']['text']['text'] = $output;
     return $Block;
 }