11.6. Writing a preformatter plugin

FIXME - need more about preformatters here

A typical preformatter plugin looks like this:


def cb_preformat(args):
    if args['parser'] == 'linebreaks':
        return parse(''.join(args['story']))

def parse(text):
    # A preformatter to convert linebreak to its HTML counterpart
    text = re.sub('\\n\\n+','</p><p>',text)
    text = re.sub('\\n','<br />',text)
    return '<p>%s</p>' % text