view examples/extend_parser.py @ 2491:c7b397a38422 default tip

Make it work with newer pygments
author Radomir Dopieralski <sheep-devel@sheep.art.pl>
date Sun, 10 Mar 2019 19:33:33 +0100
parents 6b0f5b41ffed
children
line wrap: on
line source

#!/usr/bin/python
# -*- coding: utf-8 -*-

"""
An example of how you can extend Hatta's parser without touching the
original code.
"""

import hatta

class MyWikiParser(hatta.WikiParser):
    """Alternative WikiParser that uses smilies with noses."""

    smilies = {
        r':-)': "smile.png",
        r':-(': "frown.png",
        r':-P': "tongue.png",
        r':-D': "grin.png",
        r';-)': "wink.png",
    }

class MyWikiPageWiki(hatta.WikiPageWiki):
    
    def __init__(self, *args, **kw):
        super(MyWikiPageWiki, self).__init__(*args, **kw)
        self.parser = MyWikiParser

if __name__=='__main__':
    config = hatta.read_config()
    wiki = hatta.Wiki(config)
    wiki.mime_map['text/x-wiki'] = MyWikiPageWiki
    hatta.main(wiki=wiki)