Skip to main content

Python3 Wrapper for GNU source-highlight

Project description

pyhilite
=====

##介绍
pyhilite是[source-highlight](https://www.gnu.org/software/src-highlite/)的Python封装。

功能是把源代码转化为特定的语法高亮文件,比如HTML、linux终端等。

##依赖
pyhilite依赖srchilite库,该库由source-highlight程序提供。在Fedora 22使用如下命令安装

# dnf install source-highlight-devel

其他发行版的包名应该类似。

##安装

./setup.py install

##使用

>>> import pyhilite
>>> h = pyhilite.SourceHighlight(outlang="html")
>>> h.highlight(input='hello.c')
'<!-- Generator: GNU source-highlight 3.1.7\nby Lorenzo Bettini\nhttp://www.lorenzobettini.it\nhttp://www.gnu.org/software/src-highlite -->\n<pre><tt><b><font color="#000080">#include</font></b> <font color="#FF0000">&lt;stdio.h&gt;</font>\n\n\n<font color="#009900">int</font> <b><font color="#000000">main</font></b><font color="#990000">(</font><font color="#009900">int</font> argc<font color="#990000">,</font> <b><font color="#0000FF">const</font></b> <font color="#009900">char</font> <font color="#990000">*</font>argv<font color="#990000">[])</font>\n<font color="#FF0000">{</font>\n <b><font color="#000000">printf</font></b><font color="#990000">(</font><font color="#FF0000">"hello world!</font><font color="#CC33CC">\\n</font><font color="#FF0000">"</font><font color="#990000">);</font>\n <b><font color="#0000FF">return</font></b> <font color="#993399">0</font><font color="#990000">;</font>\n<font color="#FF0000">}</font>\n</tt></pre>\n'
>>> h.highlight(input='hello.c', output='output.html')

详细的介绍请看[WIKI](https://github.com/wiiiky/pyhilite/wiki)

##TODO
目前pyhilite并没有实现所有srchilite的功能,因为我也没搞清楚srchilite的所有用法,会继续更新。

wiiiky@outlook.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyhilite-0.1.0.tar.gz (58.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page