Hatta Numbered Lists Branch

changeset 644:1372a7f3b1ce

Add a config option to specify a parser
author Ben
date Mon Dec 07 19:48:06 2009 +0100 (2009-12-07)
parents 870e7b10afda
children cc65a44d2f23
files hatta.py
line diff
     1.1 --- a/hatta.py	Mon Dec 07 19:29:25 2009 +0100
     1.2 +++ b/hatta.py	Mon Dec 07 19:48:06 2009 +0100
     1.3 @@ -176,6 +176,8 @@
     1.4              help='Read icons graphics from PAGE.')
     1.5          add('-w', '--hgweb', dest='hgweb', default=False,
     1.6              help='Enable hgweb access to the repository', action="store_true")
     1.7 +        add('-P', '--parser', dest='parser', metavar='PARSER',
     1.8 +            help='Use the following parser')
     1.9  
    1.10          options, args = parser.parse_args()
    1.11          for option, value in options.__dict__.iteritems():
    1.12 @@ -2026,6 +2028,14 @@
    1.13  class WikiPageWiki(WikiPageText):
    1.14      """Pages of with wiki markup use this for display."""
    1.15  
    1.16 +    def __init__(self, wiki, request, title, mime):
    1.17 +        WikiPageText.__init__(self, wiki, request, title, mime)
    1.18 +        parser = self.config.get("parser", "internal")
    1.19 +        if not (parser.lower() in ("internal")):
    1.20 +            parser = "internal"
    1.21 +        if parser == "internal":
    1.22 +            self.parser = WikiParser
    1.23 +
    1.24      def view_content(self, lines=None):
    1.25          if lines is None:
    1.26              f = self.storage.open_page(self.title)
    1.27 @@ -2035,8 +2045,8 @@
    1.28              smilies = dict((emo, link) for (link, emo) in icons)
    1.29          else:
    1.30              smilies = None
    1.31 -        content = WikiParser(lines, self.wiki_link, self.wiki_image,
    1.32 -                             self.highlight, self.wiki_math, smilies)
    1.33 +        content = self.parser(lines, self.wiki_link, self.wiki_image,
    1.34 +                              self.highlight, self.wiki_math, smilies)
    1.35          return content
    1.36  
    1.37      def wiki_math(self, math):