Back to index

moin  1.9.0~rc2
text_html.py
Go to the documentation of this file.
00001 # -*- coding: iso-8859-1 -*-
00002 """
00003     MoinMoin - HTML Parser
00004 
00005     @copyright: 2006 MoinMoin:AlexanderSchremmer
00006     @license: GNU GPL, see COPYING for details.
00007 """
00008 
00009 from MoinMoin.support.htmlmarkup import Markup
00010 from HTMLParser import HTMLParseError
00011 
00012 Dependencies = []
00013 
00014 class Parser:
00015     """
00016         Sends HTML code after filtering it.
00017     """
00018 
00019     extensions = ['.htm', '.html']
00020     Dependencies = Dependencies
00021 
00022     def __init__(self, raw, request, **kw):
00023         self.raw = raw
00024         self.request = request
00025 
00026     def format(self, formatter):
00027         """ Send the text. """
00028         try:
00029             self.request.write(formatter.rawHTML(Markup(self.raw).sanitize()))
00030         except HTMLParseError, e:
00031             self.request.write(formatter.sysmsg(1) +
00032                 formatter.text(u'HTML parsing error: %s in "%s"' % (e.msg,
00033                                   self.raw.splitlines()[e.lineno - 1].strip())) +
00034                 formatter.sysmsg(0))