dev-master
9999999-dev http://www.datati.roSymfony GeshiBundle
MIT
The Requires
by Theodor Diaconu
highlight highlighter geshi syntax highlight
Wallogit.com
2017 © Pedro Peláez
Symfony GeshiBundle
Add in the composer, (*1)
requires: {
// ...
"theodordiaconu/geshi-bundle" : "dev-master",
}
In the app/AppKernel.php file, (*2)
$bundles = array(
// ...
new DT\Bundle\GeshiBundle\DTGeshiBundle(),
);
After you have plugged it in your Symfony2 Application you have several ways to use this:, (*3)
{{ block_of_code|geshi_highlight('javascript') }}
{{ geshi_highlight(block_of_code, 'javascript') }}
$highlighter = $this->get('dt_geshi.highlighter');
$highlighted = $highlighter->highlight('<h1>Please highlight me!</h1>', 'html');
public function indexAction()
{
// ...
return $highlighter->createResponse('<h1>Hello</h1>', 'html');
return $highlighter->createResponse('<h1>This is the line with the error</h1>', 'html', 500);
}
$response = $highlighter->createJSONResponse(array('hello' => 'there'));
$highlighted = $highlighter->highlight(
'<h1>Please highlight me!</h1>',
'html',
function(\GeSHi\GeSHi $geshi){
$geshi->set_header_type(GESHI_HEADER_NONE);
}
);
$highlighter->setDefaultOptions(function($geshi){
/** @var $geshi \GeSHi\GeSHi */
$geshi->set_header_type(GESHI_HEADER_NONE);
});
// the highlighting will proceed using the settings from the Default Options
$highlighted = $highlighter->highlight('
Please highlight me!
', 'html');
// or
$highlighter->createResponse('
Hello
', 'html');
Symfony GeshiBundle
MIT
highlight highlighter geshi syntax highlight