Permalink
Browse files

- Added model field to store the pygment style configuration

  • Loading branch information...
1 parent acb3aa7 commit 244778ad07f90b9c53333c45fb425507453ad191 @chrisglass chrisglass committed Dec 14, 2010
Showing with 7 additions and 3 deletions.
  1. +2 −2 cmsplugin_pygments/cms_plugins.py
  2. +5 −1 cmsplugin_pygments/models.py
@@ -14,7 +14,7 @@ class CMSPygmentsPlugin(CMSPluginBase):
render_template = "cmsplugin_pygments/pygments.html"
def render(self, context, instance, placeholder):
- style = styles.get_style_by_name('emacs')
+ style = styles.get_style_by_name(instance.style)
formatter = HtmlFormatter(linenos=True, style=style)
html = highlight(instance.code,
get_lexer_by_name(instance.code_language), formatter
@@ -25,4 +25,4 @@ def render(self, context, instance, placeholder):
'placeholder':placeholder})
return context
-plugin_pool.register_plugin(CMSPygmentsPlugin)
+plugin_pool.register_plugin(CMSPygmentsPlugin)
@@ -1,6 +1,10 @@
from django.db import models
from cms.models import CMSPlugin
+from pygments.style import STYLE_MAP
+
+STYLE_CHOICES = map(lambda x: (x,x), STYLE_MAP.keys())
class PygmentsPlugin(CMSPlugin):
code_language = models.CharField(max_length=20)
- code = models.TextField()
+ code = models.TextField()
+ style = models.CharField(max_length=255, choices=STYLE_CHOICES)

0 comments on commit 244778a

Please sign in to comment.