Hatta Devel

view examples/extend_parser.py @ 887:7540675ffe4e

re-merge the fix for #79
author Radomir Dopieralski <sheep-devel@sheep.art.pl>
date Sun Feb 05 09:48:12 2012 +0100 (3 months ago)
parents 09d10de2d623
children
line source
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
4 """
5 An example of how you can extend Hatta's parser without touching the
6 original code.
7 """
9 import hatta
11 class MyWikiParser(hatta.WikiParser):
12 """Alternative WikiParser that uses smilies with noses."""
14 smilies = {
15 r':-)': "smile.png",
16 r':-(': "frown.png",
17 r':-P': "tongue.png",
18 r':-D': "grin.png",
19 r';-)': "wink.png",
20 }
22 class MyWikiPageWiki(hatta.WikiPageWiki):
24 def __init__(self, *args, **kw):
25 super(MyWikiPageWiki, self).__init__(*args, **kw)
26 self.parser = MyWikiParser
28 if __name__=='__main__':
29 config = hatta.read_config()
30 wiki = hatta.Wiki(config)
31 wiki.mime_map['text/x-wiki'] = MyWikiPageWiki
32 hatta.main(wiki=wiki)