Back to index

moin  1.9.0~rc2
Classes | Functions | Variables
MoinMoin.converter.text_html_text_moin_wiki Namespace Reference

Classes

class  visitor
class  strip_whitespace
class  convert_tree

Functions

def get_attrs
def parse
def convert

Variables

tuple interwiki_re = re.compile(WikiParser.interwiki_rule, re.VERBOSE|re.UNICODE)
string dtd = ur''

Detailed Description

    MoinMoin - convert from html to wiki markup

    @copyright: 2005-2006 Bastian Blank, Florian Festi, Reimar Bauer,
        2005-2007 MoinMoin:ThomasWaldmann
    @license: GNU GPL, see COPYING for details.

Function Documentation

def MoinMoin.converter.text_html_text_moin_wiki.convert (   request,
  pagename,
  text 
)

Definition at line 1434 of file text_html_text_moin_wiki.py.

01434 
01435 def convert(request, pagename, text):
01436     # Due to expat needing explicitly set namespaces, we set these here to allow pasting
01437     # from Word / Excel without issues.
01438     # If you encounter 'ExpatError: unbound prefix', try adding the namespace to the list.
01439     namespace = [u'xmlns:o="urn:schemas-microsoft-com:office:office"',
01440                  u'xmlns:x="urn:schemas-microsoft-com:office:excel"',
01441                  u'xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"',
01442                  u'xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet"',
01443                  u'xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"',
01444                  u'xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"',
01445                  u'xmlns:rs="urn:schemas-microsoft-com:rowset"',
01446                  u'xmlns:z="#RowsetSchema"',
01447                  u'xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml"',
01448                  u'xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core"',
01449                  u'xmlns:aml="http://schemas.microsoft.com/aml/2001/core"',
01450                  u'xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"',
01451                  u'xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint"',
01452                  u'xmlns:w10="urn:schemas-microsoft-com:office:word"',
01453                  u'xmlns:v="urn:schemas-microsoft-com:office:vml"']
01454     text = u'<page %s>%s</page>' % (' '.join(namespace), text)
01455     tree = parse(request, text)
01456     strip_whitespace().do(tree)
01457     text = convert_tree(request, pagename).do(tree)
01458     text = '\n'.join([s.rstrip() for s in text.splitlines()] + ['']) # remove trailing blanks
01459     return text
01460 

Here is the call graph for this function:

get the attributes of <node> into an easy-to-use dict 

Definition at line 1403 of file text_html_text_moin_wiki.py.

01403 
01404 def get_attrs(node):
01405     """ get the attributes of <node> into an easy-to-use dict """
01406     attrs = {}
01407     for attr_name in node.attributes.keys():
01408         # get attributes of style element
01409         if attr_name == "style":
01410             for style_element in node.attributes.get(attr_name).nodeValue.split(';'):
01411                 if style_element.strip() != '':
01412                     style_elements = style_element.split(':')
01413                     if len(style_elements) == 2:
01414                         attrs[style_elements[0].strip()] = style_elements[1].strip()
01415         # get attributes without style element
01416         else:
01417             attrs[attr_name] = node.attributes.get(attr_name).nodeValue
01418     return attrs
01419 

Here is the caller graph for this function:

Definition at line 1420 of file text_html_text_moin_wiki.py.

01420 
01421 def parse(request, text):
01422     text = u'<?xml version="1.0"?>%s%s' % (dtd, text)
01423     text = text.encode(config.charset)
01424     try:
01425         return xml.dom.minidom.parseString(text)
01426     except xml.parsers.expat.ExpatError, msg:
01427         # this sometimes crashes when it should not, so save the stuff to analyze it:
01428         logname = os.path.join(request.cfg.data_dir, "expaterror.log")
01429         f = file(logname, "w")
01430         f.write(text)
01431         f.write("\n" + "-"*80 + "\n" + str(msg))
01432         f.close()
01433         raise ConvertError('ExpatError: %s (see dump in %s)' % (msg, logname))

Here is the caller graph for this function:


Variable Documentation

Definition at line 25 of file text_html_text_moin_wiki.py.

tuple MoinMoin.converter.text_html_text_moin_wiki.interwiki_re = re.compile(WikiParser.interwiki_rule, re.VERBOSE|re.UNICODE)

Definition at line 18 of file text_html_text_moin_wiki.py.