~ubuntu-branches/ubuntu/natty/moin/natty-updates

« back to all changes in this revision

Viewing changes to MoinMoin/parser/text_html.py

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-22 21:17:13 UTC
  • mfrom: (0.9.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080622211713-fpo2zrq3s5dfecxg
Tags: 1.7.0-3
Simplify /etc/moin/wikilist format: "USER URL" (drop unneeded middle
CONFIG_DIR that was wrongly advertised as DATA_DIR).  Make
moin-mass-migrate handle both formats and warn about deprecation of
the old one.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: iso-8859-1 -*-
 
2
"""
 
3
    MoinMoin - HTML Parser
 
4
 
 
5
    @copyright: 2006 MoinMoin:AlexanderSchremmer
 
6
    @license: GNU GPL, see COPYING for details.
 
7
"""
 
8
 
 
9
from MoinMoin.support.htmlmarkup import Markup
 
10
from HTMLParser import HTMLParseError
 
11
 
 
12
Dependencies = []
 
13
 
 
14
class Parser:
 
15
    """
 
16
        Sends HTML code after filtering it.
 
17
    """
 
18
 
 
19
    extensions = ['.htm', '.html']
 
20
    Dependencies = Dependencies
 
21
 
 
22
    def __init__(self, raw, request, **kw):
 
23
        self.raw = raw
 
24
        self.request = request
 
25
 
 
26
    def format(self, formatter):
 
27
        """ Send the text. """
 
28
        try:
 
29
            self.request.write(formatter.rawHTML(Markup(self.raw).sanitize()))
 
30
        except HTMLParseError, e:
 
31
            self.request.write(formatter.sysmsg(1) +
 
32
                formatter.text(u'HTML parsing error: %s in "%s"' % (e.msg,
 
33
                                  self.raw.splitlines()[e.lineno - 1].strip())) +
 
34
                formatter.sysmsg(0))