2017 © Pedro Peláez
 

symfony-bundle geshi-bundle

Symfony GeshiBundle

image

theodordiaconu/geshi-bundle

Symfony GeshiBundle

  • Friday, March 29, 2013
  • by theodorDiaconu
  • Repository
  • 1 Watchers
  • 1 Stars
  • 260 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 1 % Grown

The README.md

DTGeshiBundle

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(),
);

How to use

After you have plugged it in your Symfony2 Application you have several ways to use this:, (*3)

Twig

{{ block_of_code|geshi_highlight('javascript') }}

{{ geshi_highlight(block_of_code, 'javascript') }}

PHP

To get the highlighter

$highlighter = $this->get('dt_geshi.highlighter');

Simple highlighting

$highlighted = $highlighter->highlight('<h1>Please highlight me!</h1>', 'html');

To create a response that highlights everything automatically for you

public function indexAction()
{
    // ...
    return $highlighter->createResponse('<h1>Hello</h1>', 'html');
    return $highlighter->createResponse('<h1>This is the line with the error</h1>', 'html', 500);
}

Also, for bad ass people I have also plugged in another method:

$response = $highlighter->createJSONResponse(array('hello' => 'there'));

If you want flexibility in configuring the output, you've got it.

$highlighted = $highlighter->highlight(
    '<h1>Please highlight me!</h1>',
    'html',
    function(\GeSHi\GeSHi $geshi){
        $geshi->set_header_type(GESHI_HEADER_NONE);
    }
);

How to set default options to GeSHi

$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');

The Versions

29/03 2013

dev-master

9999999-dev http://www.datati.ro

Symfony GeshiBundle

  Sources   Download

MIT

The Requires

 

by Theodor Diaconu

highlight highlighter geshi syntax highlight