Mercurial > piecrust2
changeset 293:d013cc191922
jinja: Add a global function to render Pygments' CSS styles.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 08 Mar 2015 22:58:28 -0700 |
parents | c8a6c92b1867 |
children | f51b69ad09ae |
files | piecrust/templating/jinjaengine.py |
diffstat | 1 files changed, 6 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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'])