/** * Transforms a given block into HTML using Geshi syntax highlighting. * * @param $matches * @param string $default * @return mixed|string */ protected function transformGeshiBlock($matches, $default = '') { if (preg_match('/^\\[(.+?)\\]\\s*(.+)$/s', $matches[1], $match)) { return sfGeshi::parse_single(html_entity_decode($match[2]), $match[1]); } if ($default) { $geshi = new sfGeshi(html_entity_decode($matches[1]), $default); $geshi->enable_classes(); return $geshi->parse_code(); } return "<pre><code>" . $matches[1] . '</pre></code>'; }
/** * Integrate Geshi highlighting into matched blocks * * @param array $matches * @param string $default * @return string */ private static function geshiHighlighter($matches, $default = '') { if (preg_match('/^\\[(.+?)\\]\\s*(.+)$/s', $matches[1], $match)) { //$geshi = new sfGeshi(html_entity_decode($match[2]), $match[1]); return sfGeshi::parse_single(html_entity_decode($match[2]), $match[1]); } if (preg_match('/^\\[(.+?)\\]\\s*(.+)$/s', $matches[1], $match)) { $geshi = new sfGeshi(html_entity_decode($match[2]), $match[1]); return $geshi->parse_single(); } else { if ($default) { $geshi = new sfGeshi(html_entity_decode($matches[1]), $default); $geshi->enable_classes(); return $geshi->parse_code(); } else { return "<pre><code>" . $matches[1] . '</pre></code>'; } } }