uran1980 / yii2-code-prettify
基于 Google-Code-Prettify 库的 Yii2 代码语法高亮器。
0.0.2
2015-03-07 00:00 UTC
Requires
- bower-asset/google-code-prettify: *
- yiisoft/yii2: ~2
This package is auto-updated.
Last update: 2024-09-13 04:42:02 UTC
README
基于 Google-Code-Prettify 的代码语法高亮。
安装
Composer
安装此扩展的首选方式是通过 Composer。
运行以下命令之一
php composer.phar require uran1980/yii2-code-prettify "dev-master"
或者
"uran1980/yii2-code-prettify": "dev-master"
将以下内容添加到您的 composer.json
文件的 require 部分中
使用方法
要使用此组件,请将其依赖项添加到您项目的资源包中。例如,在 ...\frontend\assets\AppAsset.php
文件中添加以下依赖项
<?php namespace frontend\assets; class AppAsset extends \yii\web\AssetBundle { ... public $depends = [ ... 'uran1980\yii\assets\codePrettify\CodePrettifyAsset', ]; }
这样就完成了。在视图中添加如下源代码块
<pre class="prettyprint"> <script type="text/javascript"> // Say hello world until the user starts questioning // the meaningfulness of their existence. function helloWorld(world) { for (var i = 42; --i >= 0;) { alert('Hello ' + String(world)); } } </script> <style> p { color: pink } b { color: blue } u { color: "umber" } </style> </pre> ## Author [Ivan Yakovlev](https://github.com/uran1980/), e-mail: [uran1980@gmail.com](mailto:uran1980@gmail.com)