Ejemplo n.º 1
0
def parse(*args):
    try:
        
        wikitext = wikitext_entry.get("1.0", 'end')
        settings.loadWikiText(wikitext)
        options = settings.getOptions()
        
        scanner = Scanner()
        scanner.loadTree('data/wikitree2.xml')
        scanner.loadFile('parser/source/wikiSource.wiki')
        scanResult = scanner.scan()
        print scanResult

        parser = Parser()
        parser.loadTokenList(scanResult, options)
        parser.parse()
        
        htmltext = settings.loadHtmlText()
        print "htmltext"
        print htmltext
        htmltext_entry.delete("1.0", 'end')
        htmltext_entry.insert("1.0", htmltext)
#        try:
#            os.remove('pages/C.wiki')
#            os.remove('pages/C.html')
#        except:
#            None
    except ValueError:
        pass
Ejemplo n.º 2
0
                    break
                elif specialTag != '' and specialTag != None: 
                    [newToken , inc] = self.import_modules.parse_special(specialTag)
                    self.count= self.count + inc -1 
                    retTag.appendChild(newToken)
                else:
                    
                    newToken = self.parseToken(token , self.parser_tree_helper.getEndingTag(token))
                    retTag.appendChild(newToken);
                
            else:
                ptext = self.doc.createTextNode(token)
                retTag.appendChild(ptext)
                
        return retTag



if __name__ == '__main__':
    scanner = Scanner()
    scanner.loadTree('../data/wikitree2.xml')
    scanner.loadFile('../data/testfile')
    result = scanner.scan()
    Parser.clearListFromEmptyTokens(result)
    parser = Parser()
    parser.setTokenList(result)
    parser.parse()
    print result
    docc = parser.retDoc()
    print docc.toprettyxml(indent="  ")