1<?php 2 3class syntax_plugin_codeprism_fileprism extends syntax_plugin_codeprism_codeprism 4{ 5 protected $entry_pattern = '<fileprism\b.*/>'; 6 protected $exit_pattern = '/>'; 7 protected $match_pattern = '/<fileprism (.+?)( \[(.+?)\])* *\/>/'; 8 9 public function connectTo($mode) 10 { 11 if (isset($_REQUEST['comment'])) return false; 12 13 $this->Lexer->addEntryPattern($this->entry_pattern, $mode, 'plugin_codeprism_fileprism'); 14 } 15 16 public function postConnect() 17 { 18 $this->Lexer->addExitPattern($this->exit_pattern, 'plugin_codeprism_fileprism'); 19 } 20 21 public function render($mode, Doku_Renderer $renderer, $data) 22 { 23 if ($mode != 'xhtml') return false; 24 25 list($state) = $data; 26 27 switch ($state) { 28 case DOKU_LEXER_ENTER: 29 list(, $pre_opt_arr, $code_opt_arr) = $data; 30 31 $renderer->doc .= '<pre class="dokuwiki-plugin-codeprism-'.$pre_opt_arr['css'].' '.$pre_opt_arr['line-numbers'] . '"'; 32 unset($pre_opt_arr['line-numbers']); 33 unset($pre_opt_arr['css']); 34 35 foreach($pre_opt_arr as $key => $val) { 36 $renderer->doc .= ' ' . $key . '="' . $val . '"'; 37 } 38 39 $renderer->doc .='>'; 40 break; 41 42 case DOKU_LEXER_EXIT: 43 $renderer->doc .= '</pre>'; 44 break; 45 } 46 47 return false; 48 } 49} 50