yii-prettify Syntax highlighting tool of source code snippets

  1. Requirements
  2. Usage
  3. Change log
  4. Resources

This widget enable syntax highlighting of code snippets in your web application using Google Code Prettify.

Requirements

Yii 1.1.6 or above...(tested with 1.1.10)

Usage

  • install and explore the demo application
  • or extract the widget file under .../protected/extensions
  • put in a view a code block like the following...
Sample : HTML code
<?php $this->beginWidget('ext.prettify.JPrettify');?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Code Sample</title>
  </head>
  <body>
    <b>Hello World!</b>
  </body>
</html>
<?php $this->endWidget();?>
Sample : PHP code from file
<?php
$this->widget('ext.prettify.JPrettify',array(
    'lang'=>"php5",
    'showLineNumbers'=>true,
    'pathAlias'=>"system.base",
    'fileName'=>"CComponent.php",
    'htmlOptions'=>array('style'=>'max-height: 340px; overflow-y: scroll;')
));
?>
Sample : HTML5 code from any website
<?php
$this->widget('ext.prettify.JPrettify',array(
    'fileName'=>"http://www.yiiframework.com/",
    'htmlOptions'=>array('style'=>'max-height: 600px; overflow-y: scroll;'))
);
?>

Change log

Version 1.0
  • initial release
Version 1.1
  • code cleaning
  • bug fix
  • better support for highlighting of PHP5 keywords

Resources

Google Code Prettify
Alternate Yii extension
3 0
5 followers
1 105 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: User Interface
Developed by: volkmar
Created on: Jun 17, 2012
Last updated: 5 years ago

Downloads

show all

Related Extensions