There exist different ways for highlight sourcecode with pygments:

sourcecode django tag

example:

HTML+Django/Jinja
1
2
3
{% sourcecode ext=".py" %}
print "Python is cool!"
{% endsourcecode %}

result:

1
print "Python is cool!"

Info:

  • With this method the code can contain django template tags, except the sourcecode tag :)
  • You didn't see the result in "markup preview"!

creole markup macro

PyLucid has a creole markup macro for highlighting:

<<code ext=.FOO>>...<</code>>

(Where FOO is the fileextension of the sourcecode)

example:

<<code ext=.css>>
.xs {font-family:verdana,arial,helvetica,sans-serif;font-size: x-small}
.m {font-size: medium}
<</code>>

output is:

1
2
.xs {font-family:verdana,arial,helvetica,sans-serif;font-size: x-small}
.m {font-size: medium}

Important:

  • The sourcecode should no contain syntax like django template tags!

generate html code for copy&paste

You can generate html code for copy&paste into page content with:

  • PyLucid Admin Menü/tools/hightlight code

E.g.: with Creole markup, put the generated html code into:
<<html>>...<</html>>

Info:

  • With this method the code can contain django template tags.