[Moin-devel] CVS: MoinMoin/parser rst.py,NONE,1.1

J?rgen Hermann jhermann at users.sourceforge.net
Thu May 9 03:33:02 EDT 2002


Update of /cvsroot/moin/MoinMoin/parser
In directory usw-pr-cvs1:/tmp/cvs-serv1861

Added Files:
	rst.py 
Log Message:
RST parser which (currently) converts to XML


--- NEW FILE: rst.py ---
"""
    MoinMoin - ReStructured Text Parser

    Copyright (c) 2002 by Jürgen Hermann <jh at web.de>
    All rights reserved, see COPYING for details.

    $Id: rst.py,v 1.1 2002/05/09 10:32:15 jhermann Exp $
"""

import cgi, sys
from docutils import core, utils
from docutils.parsers import rst


#############################################################################
### ReStructured Text Parser
#############################################################################

class Parser:
    """ Parse ReST via "docutils".
    """

    def __init__(self, raw, request, **kw):
        self.raw = raw
        self.request = request

    def format(self, formatter, form):
        """ Send the text.
        """
        #core.publish(source=self.raw, destination=sys.stdout, writer_name='html')

        parser = rst.Parser()
        document = utils.new_document()
        parser.parse(self.raw, document)

        if 1:
            dom = document.asdom()
            print '<pre>'
            print cgi.escape(dom.toprettyxml(indent='  '))
            print '</pre>'

        if 0:
            print '<pre>'
            print cgi.escape(document.astext())
            print '</pre>'






More information about the Moin-devel mailing list