Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add a line about passing keyword arguments to HtmlFormatter from temp…

…late tag in the README.

Also add a sample in the demo.html.
  • Loading branch information...
commit 7a98a73457ee81f2bb52de4906bb446809bd01aa 1 parent 504607a
@madhusudancs madhusudancs authored
Showing with 4 additions and 1 deletion.
  1. +1 −0  README
  2. +3 −1 django_pygments/templates/django_pygments/demo.html
View
1  README
@@ -11,6 +11,7 @@ Usage:
- enclose your code snippet in a pre tag with the non-standard "lang" attribute set to a supported language like this:
<pre lang="python">....</pre>
- see the view and demo template for examples on how to use the "pygmentify" and "pygmentify_inline" filters (the later is rather useful for RSS feeds) or the "pygment" tag
+- While using the "pygment" template tag, you can pass keyword arguments that you would pass to Pygments HtmlFormatter class constructor by passing them as with keyword arguments along with the pygment tag. Look at demo template for examples. There is one caveat with this feature still. You can only pass Python values as argument values (like Strings wrapped within quotes or True or False boolean values, etc.). It doesn't support Django template/context variables as arguments yet.
Notes:
- the custom HTML formatter class displays each line as an ordered list element, thus implementing line numbering without interfering with copy/pasting
View
4 django_pygments/templates/django_pygments/demo.html
@@ -21,7 +21,9 @@
{{ snippet|pygmentify_inline }}
<br />
<h3>the "pygment" tag</h3>
- {% pygment %}
+ <!-- lineseparator="<br/><br/>" will be passed as keyword
+ argument to the HtmlFormatter class -->
+ {% pygment lineseparator="<br/><br/>" %}
<pre lang="bash">
stefan$ ./manage.py runserver_cp
Validating models...
Please sign in to comment.
Something went wrong with that request. Please try again.