kzykhys/pygments

此包的最新版本(v1.0.0)没有可用的许可证信息。

Python Pygments的轻量级包装器

v1.0.0 2013-12-18 15:22 UTC

This package is not auto-updated.

Last update: 2024-09-10 03:22:34 UTC


README

Latest Stable Version Build Status Coverage Status SensioLabsInsight

Python Pygments语法高亮器的PHP包装器

要求

  • PHP5.3+
  • Python 2.4+
  • Pygments(sudo easy_install Pygments

安装

创建或更新您的composer.json并运行composer update

{
    "require": {
        "kzykhys/pygments": ">=1.0"
    }
}

用法

高亮源代码

<?php

use KzykHys\Pygments\Pygments;

$pygments = new Pygments();
$html = $pygments->highlight(file_get_contents('index.php'), 'php', 'html');
$text = $pygments->highlight('package main', 'go', 'ansi');

生成CSS

<?php

use KzykHys\Pygments\Pygments;

$pygments = new Pygments();
$css = $pygments->getCss('monokai');
$prefixedCss = $pygments->getCss('default', '.syntax');

猜测词法分析器名称

<?php

use KzykHys\Pygments\Pygments;

$pygments = new Pygments();
$pygments->guessLexer('foo.rb'); // ruby

获取词法分析器/格式化程序/样式列表

<?php

use KzykHys\Pygments\Pygments;

$pygments = new Pygments();
$pygments->getLexers()
$pygments->getFormatters();
$pygments->getStyles();

自定义pygmentize路径

<?php

use KzykHys\Pygments\Pygments;

$pygments = new Pygments('/path/to/pygmentize');

许可证

MIT许可证

作者

Kazuyuki Hayashi (@kzykhys)