Search This Blog

Wednesday, November 4, 2009

Convert source code to syntax highlighted document

How to conver some source code to nice looking [x]html code :)?

The debian apt-cache tool is your friend. Try the following commands:

apt-cache search syntax highlighted
apt-cache search source converter
apt-cache search source color html


Some of packages, which I found:

code2html - Syntax highlighter
src2tex - A converter from source program files to TeX format files
highlight - An universal source code to formatted text converter
txt2html - Text to HTML converter
src2tex - A converter from source program files to TeX format files
c2html - Highlight C sources for WWW presentation
source-highlight - convert source code to syntax highlighted document
webcpp - configurable utility to convert source code to HTML

Example:

$ source-highlight -n -d -o sample.html -s python -i sample.py

01:
#!/usr/bin/python
02:
03: import sys, re
04:
05: class HelloWorld:
06: def helloWorld(self):
07: print "hallo world :)"
08:
09:
10: if __name__ == "__main__":
11: helloWorld=HelloWorld()
12: helloWorld.helloWorld()

No comments:

Post a Comment