# HG changeset patch # User Ludovic Chabant # Date 1425880708 25200 # Node ID d013cc191922af1601401c5f0f1d55fa443bf6eb # Parent c8a6c92b18671cb0e3e41a4f91c81442e08c6414 jinja: Add a global function to render Pygments' CSS styles. diff -r c8a6c92b1867 -r d013cc191922 piecrust/templating/jinjaengine.py --- a/piecrust/templating/jinjaengine.py Sat Mar 07 22:53:35 2015 -0800 +++ b/piecrust/templating/jinjaengine.py Sun Mar 08 22:58:28 2015 -0700 @@ -133,7 +133,8 @@ # Now add globals and filters. self.globals.update({ - 'fail': raise_exception}) + 'fail': raise_exception, + 'highlight_css': get_highlight_css}) self.filters.update({ 'keys': get_dict_keys, @@ -332,6 +333,10 @@ return code +def get_highlight_css(class_name='.highlight'): + return HtmlFormatter().get_style_defs(class_name) + + class PieCrustCacheExtension(Extension): tags = set(['pccache', 'cache'])