uran1980/yii2-code-prettify

基于 Google-Code-Prettify 库的 Yii2 代码语法高亮器。

安装量: 6,004

依赖项: 2

建议者: 0

安全性: 0

星标: 1

关注者: 2

分支: 2

开放问题: 0

语言:CSS

类型:yii2-extension

0.0.2 2015-03-07 00:00 UTC

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">
&lt;script type="text/javascript"&gt;
    // Say hello world until the user starts questioning
    // the meaningfulness of their existence.
    function helloWorld(world) {
      for (var i = 42; --i &gt;= 0;) {
        alert('Hello ' + String(world));
      }
    }
&lt;/script&gt;
&lt;style&gt;
    p { color: pink }
    b { color: blue }
    u { color: "umber" }
&lt;/style&gt;
</pre>


## Author

[Ivan Yakovlev](https://github.com/uran1980/), e-mail: [uran1980@gmail.com](mailto:uran1980@gmail.com)