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.
the usage description is not enough !
看了你的主页才知道你跟我一样是中国人!呵呵
用法描述太少了,我不得不看源码,并从源码找他的根COutputProcessor ,原来是一个widget,所以你应该建议下载的文件应该放在那里 比如: components目录下或者是新建一个widgets目录(在components下或者protected下),不过放在extentions目录下也可以。还有最好加一个如果作为widget的示例用法,我现在还用不到这块所以先不研究你的扩展了!
description already expanded
@yiqing95 as your comment, description already expanded
hope you will find what you want to know. :-)
so good!
It is a good extension, thanks!
please more careful , the demo code you give didn't work!
in the filter function it should be :
return array( array( 'application.components.geshi.GeSHiHighlighter', /* yours: 'class' => 'application.components.geshi.GeSHiHighlighter',*/ 'language' => 'html', ), ); // and the alias is prefixed by application.components. not application. /* and you give a wrong method : $highlighter = Yii::createCompoent(array( 'class' => 'application.geshi.GeSHiHighlighter', 'language' => 'php', )); the 'createCompoent' should be "createComponent" */
just a little modify , :)
anyway , it's a good extension .
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.