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 details)

Uploaded Source

File details

Details for the file pyhilite-0.1.0.tar.gz.

File metadata

  • Download URL: pyhilite-0.1.0.tar.gz
  • Upload date:
  • Size: 58.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyhilite-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a514327bbf94139c700d403bbf172f5622eb0672dd5b798bf57c4da53d18a63d
MD5 4e0fdcad71d2e0fea4766a20a940fc89
BLAKE2b-256 099674035196f31b2df269a8ea48a6aba110990284bd79480f2d480e912ded9f

See more details on using hashes here.

Supported by

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