GNU源高亮C++库的Python 3绑定
pyhilite的Python项目详细描述
介绍 pyhilite是python3绑定的gnu源亮点。
given a source file, produces a document with syntax highlighting
有关详细信息,请参阅[src highlite](https://www.gnu.org/software/src-highlite/)
##依赖关系 赤铁矿取决于GNU源高亮C++突出显示库。
对于Fedora22
# dnf install source-highlight-devel
对于ubuntu15.04
# apt-get install libsource-highlight-dev
其他linux发行版的包名称应该类似。
##安装
pip3 install pyhilite
##示例
>>> 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"><stdio.h></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')
屏幕截图 ![hicat.py](https://github.com/wiiiky/pyhilite/blob/master/screenshot.png)