allowed lexer to be varied
authorandy
Thu, 17 Dec 2009 16:18:34 +0000
changeset 3290 6e5e33a15a3d
parent 3289 58fcf065b4e0
child 3291 bd18d83b4a0d
allowed lexer to be varied
src/reportlab/lib/abag.py
src/reportlab/lib/colors.py
src/reportlab/lib/pygments2xpre.py
--- a/src/reportlab/lib/abag.py	Thu Dec 17 13:02:51 2009 +0000
+++ b/src/reportlab/lib/abag.py	Thu Dec 17 16:18:34 2009 +0000
@@ -1,4 +1,4 @@
-#Copyright ReportLab Europe Ltd. 2000-2004
+#Copyright ReportLab Europe Ltd. 2000-2010
 #see license.txt for license details
 #history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/lib/abag.py
 __version__=''' $Id$ '''
--- a/src/reportlab/lib/colors.py	Thu Dec 17 13:02:51 2009 +0000
+++ b/src/reportlab/lib/colors.py	Thu Dec 17 16:18:34 2009 +0000
@@ -1,4 +1,4 @@
-#Copyright ReportLab Europe Ltd. 2000-2004
+#Copyright ReportLab Europe Ltd. 2000-2010
 #see license.txt for license details
 #history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/lib/colors.py
 __version__=''' $Id$ '''
--- a/src/reportlab/lib/pygments2xpre.py	Thu Dec 17 13:02:51 2009 +0000
+++ b/src/reportlab/lib/pygments2xpre.py	Thu Dec 17 16:18:34 2009 +0000
@@ -5,6 +5,8 @@
 calling 'pygments2xpre' will return content suitable for display in
 an XPreformatted object.  If it's not installed, you won't get colours.
 
+For a list of available lexers see http://pygments.org/docs/
+
 """
 __all__ = ('pygments2xpre',)
 
@@ -19,16 +21,18 @@
         s = s.replace('<span class="%s">' % k,'<font color="%s">' % c)
     return s
 
-def pygments2xpre(s):
+def pygments2xpre(s, language="python"):
     "Return markup suitable for XPreformatted"
     try:
         from pygments import highlight
-        from pygments.lexers import PythonLexer
         from pygments.formatters import HtmlFormatter
     except ImportError:
         return s
 
-    l = PythonLexer()
+    from pygments.lexers import get_lexer_by_name
+
+    l = get_lexer_by_name(language)
+    
     h = HtmlFormatter()
     from StringIO import StringIO
     out = StringIO()