pygments_style can be an import path now

This commit is contained in:
Armin Ronacher 2008-04-28 13:22:14 +00:00
parent df27e62743
commit 2e96cea026
2 changed files with 14 additions and 3 deletions

10
CHANGES
View File

@ -1,3 +1,13 @@
Release 0.3 (TBA)
=================
New features added
------------------
* If the `pygments_style` contains a dot it's treated as import path and
used as style class.
Release 0.2 (Apr 27, 2008)
==========================

View File

@ -87,10 +87,11 @@ class PygmentsBridge(object):
return
if stylename == 'sphinx':
style = SphinxStyle
elif isinstance(stylename, basestring):
style = get_style_by_name(stylename)
elif '.' in stylename:
module, stylename = stylename.rsplit('.', 1)
style = getattr(__import__(module, None, None, ['']), stylename)
else:
style = stylename
style = get_style_by_name(stylename)
self.hfmter = {False: HtmlFormatter(style=style),
True: HtmlFormatter(style=style, linenos=True)}
self.lfmter = {False: LatexFormatter(style=style),