Mercurial > piecrust2
diff piecrust/formatting/smartypantsformatter.py @ 76:fdb08d986384 2.0.0-alpha2
Add SmartyPants formatting.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 30 Aug 2014 17:35:11 -0700 |
parents | |
children | 370e74941d32 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/piecrust/formatting/smartypantsformatter.py Sat Aug 30 17:35:11 2014 -0700 @@ -0,0 +1,22 @@ +import smartypants +from piecrust.formatting.base import Formatter, PRIORITY_LAST + + +class SmartyPantsFormatter(Formatter): + FORMAT_NAMES = ['html'] + OUTPUT_FORMAT = 'html' + + def __init__(self): + super(SmartyPantsFormatter, self).__init__() + self.priority = PRIORITY_LAST + + def initialize(self, app): + super(SmartyPantsFormatter, self).initialize(app) + self.enabled = ( + app.config.get('smartypants/enable') or + app.config.get('smartypants/enabled')) + + def render(self, format_name, txt): + assert format_name == 'html' + return smartypants.smartypants(txt) +