Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- Added model field to store the pygment style configuration

  • Loading branch information...
commit 244778ad07f90b9c53333c45fb425507453ad191 1 parent acb3aa7
@chrisglass chrisglass authored
View
4 cmsplugin_pygments/cms_plugins.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)
View
6 cmsplugin_pygments/models.py
@@ -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)
Please sign in to comment.
Something went wrong with that request. Please try again.