geshi-highlighter highlight code by GeSHi engine

  1. Requirements
  2. Usage
  3. Resources

Using GeSHi highlight engine to highlight, to instead CTextHighlighter because it's poor language support.

Requirements

Yii 1.1 or above,
Other not tested.

Usage

put files into application.components;

Thanks for yiqing95's help :=) http://www.yiiframework.com/extension/geshi-highlighter/#c4321

when using like a COutputFilter, just like other filter.
for more detail, check here
and there's a example below

define an array in CController::filters like this

public function filters()
{
    return array(
        array('application.geshi.GeSHiHighlighter',
              'language' => 'html',
        ),
        .....
    );
}

when using standalone, following codes below:

$highlighter = Yii::createComponent(array(
    'class' => 'application.geshi.GeSHiHighlighter',
    'language' => 'php',
));

echo $highlighter->highlight('<?php echo "Hello World"; ?>');

tips: you can set the htmlOptions for code container by codes below:

$highlighter->containerOptions = array(
    'class' => 'cb_highlight',
);

BE ADVISED, only ID, CLASS, STYLE are supported.

Resources

4 1
5
620
Yii Version: 1.1
License: BSD-2-Clause
Category: Others
Developed by: Francis.TM Francis.TM
Created: May 26, 2011
Updated: 15 years ago

Downloads

show all

Related Extensions