diff options
author | René 'Necoro' Neumann <necoro@necoro.net> | 2010-04-07 00:24:51 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.net> | 2010-04-07 00:24:51 +0200 |
commit | f11fff031cbd632b50951bc9df04efa827cd59f7 (patch) | |
tree | e4d5372de7cec6de4fcf9d1545bd0ab33ad8409b /highlighting.py | |
parent | 57a848b2e1510ba7108b986d5a7a696959c5e732 (diff) | |
download | web-f11fff031cbd632b50951bc9df04efa827cd59f7.tar.gz web-f11fff031cbd632b50951bc9df04efa827cd59f7.tar.bz2 web-f11fff031cbd632b50951bc9df04efa827cd59f7.zip |
Add highlighting support
Diffstat (limited to '')
-rw-r--r-- | highlighting.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/highlighting.py b/highlighting.py new file mode 100644 index 0000000..9308b84 --- /dev/null +++ b/highlighting.py @@ -0,0 +1,16 @@ +from pygments import highlight as pygHighlight +from pygments.lexers import get_lexer_by_name +from pygments.formatters import HtmlFormatter + +formatter = HtmlFormatter(encoding = "utf-8", classprefix="pygm", nowrap=True) + +def highlight(context, code, lang): + l = get_lexer_by_name(lang, encoding = "utf-8") + context.write(pygHighlight(code, l, formatter)) + return '' + +def get_css(context): + context.write("""<style type="text/css"> +%s +</style>""" % formatter.get_style_defs()) + return '' |