定制 magdkudama/twig-highlight 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

magdkudama/twig-highlight

Composer 安装命令:

composer require magdkudama/twig-highlight

包简介

Twig extension to highlight content

README 文档

README

Build Status

Simple extension to highlight code (it could be done using a filter or a function, of course... but why not with a custom tag? :D).

Installing

Add the dependency to the composer.json file:

{
    "require": {
        "magdkudama/twig-highlight": "dev-master"
    }
}

A minimum working version:

<?php

use MagdKudama\Highlight\Extension;
use MagdKudama\Highlight\Engine\PygmentsRenderer;

$twig = // Initialize Twig!

$twig->addExtension(new Extension(new PygmentsRenderer()));

Usage

{% highlight 'php' with { theme: 'vim' } ignore_errors %}
    <?php

    echo "Hello World!";

    for ($i = 0; $i < 10; $i++) {
        echo $i;
    }
{% endhighlight %}

{% highlight 'php' with { theme: 'vim' } %}
    ... code here ...
{% endhighlight %}

{% highlight 'php' %}
    ... code here ...
{% endhighlight %}

{% highlight 'php' ignore_errors %}
    ... code here ...
{% endhighlight %}

The language (php in this case) is required, but the parameters (with {} and ignore_errors are optional).

If you don't want to use Pygments, you can create your own engine by implementing the MagdKudama\Highlight\Engine interface.

TODO

  • Support... Maybe Geshi?
  • Default content when there's an error... Maybe!

License

Twig highlight extension is licensed under the MIT license.

Contributors

  • Magd Kudama [magdkudama]

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-11-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固