/** * @param string $content * @param string $language * @param array $parameters * @return string */ public function getOutputFor($content, $language, array $parameters = []) { $parser = new Pygments(); $styles = ''; if (isset($parameters['theme'])) { $styles .= '<style>' . $parser->getCss($parameters['theme']) . '</style>'; } return $styles . $parser->highlight($content, $language, 'html'); }
public function execute() { global $wgPygmentizePath; $target = __DIR__ . '/../modules/pygments.generated.css'; $pygments = new Pygments($wgPygmentizePath); $css = "/* Stylesheet generated by updateCSS.php */\n"; $css .= $pygments->getCss('default', '.' . SyntaxHighlight_GeSHi::HIGHLIGHT_CSS_CLASS); if (file_put_contents($target, $css) === false) { $this->output("Failed to write to {$target}\n"); } else { $this->output('CSS written to ' . realpath($target) . "\n"); } }
/** * @dataProvider provideCss */ public function testGetCss($expected, $expectedA, $style) { $pygments = new Pygments(); $this->assertEquals($expected, $pygments->getCss($style)); $this->assertEquals($expectedA, $pygments->getCss($style, '.syntax')); }