#!/usr/bin/env python # $Log: pygmentize,v $ # Revision 1.3 2007/07/04 19:54:26 majid # cope with Unicode characters in source # # Revision 1.2 2006/12/23 03:51:03 majid # import pygments.lexers and pygments.formatters explicitly due to Pygments 0.6 # # Revision 1.1 2006/12/05 20:19:57 majid # Initial revision # """ CVStrac plugin to Pygmentize source code """ import sys, pygments, pygments.lexers, pygments.formatters def main(): assert len(sys.argv) == 2 block = sys.stdin.read() try: lexer = pygments.lexers.get_lexer_for_filename(sys.argv[1]) out = pygments.highlight block = pygments.highlight( block, lexer, pygments.formatters.HtmlFormatter( style='colorful', linenos=True, full=True)) except ValueError: pass print unicode(block).encode('ascii', 'xmlcharrefreplace') if __name__ == '__main__': main()