aboutsummaryrefslogtreecommitdiffstats
path: root/highlight.py
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-04-20 03:16:28 +0000
committerDavid Robillard <d@drobilla.net>2009-04-20 03:16:28 +0000
commit815991c906f912c4eb52e1d3646a6110d472a8ec (patch)
tree302f7c4ee9e8d9f491e1154d89b383f0ec241f40 /highlight.py
parent724a55ba4de8ba8e26d660a7c60eb0bf89ec9354 (diff)
downloadresp-815991c906f912c4eb52e1d3646a6110d472a8ec.tar.gz
resp-815991c906f912c4eb52e1d3646a6110d472a8ec.tar.bz2
resp-815991c906f912c4eb52e1d3646a6110d472a8ec.zip
Clean up.
git-svn-id: http://svn.drobilla.net/resp/tuplr@117 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'highlight.py')
-rwxr-xr-xhighlight.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/highlight.py b/highlight.py
index a26d239..c48831d 100755
--- a/highlight.py
+++ b/highlight.py
@@ -106,6 +106,14 @@ infile = open(sys.argv[1], 'r')
text = infile.read()
infile.close()
+
+if re.match('.*\.html$', sys.argv[2]):
+ style = TuplrStyleDark
+ formatter = HtmlFormatter(style=style)
+elif re.match('.*\.tex$', sys.argv[2]):
+ style = TuplrStyleLight
+ formatter = LatexFormatter(style=style)
+
if re.match('.*\.html$', sys.argv[2]):
outfile = open(sys.argv[2], 'w')
print >>outfile, '''<?xml version="1.0" encoding="UTF-8"?>
@@ -115,12 +123,12 @@ if re.match('.*\.html$', sys.argv[2]):
<head>
<title>%s</title>
<style type="text/css">''' % sys.argv[1]
- print >>outfile, HtmlFormatter(style=TuplrStyleDark).get_style_defs('.highlight')
+ print >>outfile, formatter.get_style_defs('.highlight')
print >>outfile, ''' </style>
</head>
<body>
'''
- print >>outfile, highlight(text, TuplrLexer(), HtmlFormatter(style=TuplrStyleDark))
+ print >>outfile, highlight(text, TuplrLexer(), formatter)
print >>outfile, '''</body>
</html>
'''
@@ -131,16 +139,13 @@ if re.match('.*\.tex$', sys.argv[2]):
print >>outfile, '''\\documentclass[10pt]{article}
\\usepackage{fancyvrb}
\\usepackage{color}'''
- print >>outfile, LatexFormatter(style=TuplrStyleLight).get_style_defs()
+ print >>outfile, formatter.get_style_defs()
print >>outfile, '\\newcommand\\PYlambda{$\\lambda$}'
print >>outfile, '\\newcommand\\PYbiglambda{$\\Lambda$}'
print >>outfile, '\\begin{document}'
- out = highlight(text, TuplrLexer(), LatexFormatter(style=TuplrStyleLight))
- print out
- print "******************************************************************************"
+ out = highlight(text, TuplrLexer(), formatter)
out = out.replace('[fn', '[@PYlambda')
out = out.replace('[Fn', '[@PYbiglambda')
- print out
print >>outfile, out
print >>outfile, '\\end{document}'
outfile.close()