view piecrust/formatting/smartypantsformatter.py @ 498:35d4c172e5a6

less: Fix issues with the map file on Windows. See the comment in the code for more information. Also, only wrap the opening of the map file in a try/except clause, since we want to catch the situation where the map file is missing only.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 23 Jul 2015 23:02:07 -0700
parents fdb08d986384
children 370e74941d32
line wrap: on
line source

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)