From f11fff031cbd632b50951bc9df04efa827cd59f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Wed, 7 Apr 2010 00:24:51 +0200 Subject: Add highlighting support --- highlighting.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 highlighting.py (limited to 'highlighting.py') 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("""""" % formatter.get_style_defs()) + return '' -- cgit v1.2.3