Ejemplo n.º 1
0
    def parse(self, text):
        text = text.replace(' ', 'n-b-s-p')
        text = text.replace('&', 'n-a-m-p')
        text = text.replace('&','&')
        text = text.replace('n-b-s-p', ' ')
        text = text.replace('n-a-m-p', '&')
        text = text.replace('<code>', '<pre>')
        text = text.replace('</code>', '</pre>')

        text = wikimarkup.to_unicode(text)
        text = self.strip(text)

        text = super(WikiParser, self).parse(text)
        text = self.addImage(text)
        text = self.attachDoc(text)
        text = self.recordLink(text)
        text = self.viewRecordLink(text)
        return text
Ejemplo n.º 2
0
    def parse(self, text, id):
        text = text.replace('&nbsp;', 'n-b-s-p')
        text = text.replace('&amp;', 'n-a-m-p')
        text = text.replace('&','&amp;')
        text = text.replace('n-b-s-p', '&nbsp;')
        text = text.replace('n-a-m-p', '&amp;')
        text = text.replace('<code>', '<pre>')
        text = text.replace('</code>', '</pre>')

        text = wikimarkup.to_unicode(text)
        text = self.strip(text)

        text = super(WikiParser, self).parse(text)
        text = self.addImage(text, id)
        text = self.attachDoc(text, id)
        text = self.recordLink(text)
        text = self.viewRecordLink(text)
        text = self.addInternalLinks(text)
        #TODO : already implemented but we will implement it later after releasing the 5.0
        #text = self.addRss(text, id)
        return text
Ejemplo n.º 3
0
    def parse(self, text, id):
        text = text.replace('&nbsp;', 'n-b-s-p')
        text = text.replace('&amp;', 'n-a-m-p')
        text = text.replace('&', '&amp;')
        text = text.replace('n-b-s-p', '&nbsp;')
        text = text.replace('n-a-m-p', '&amp;')
        text = text.replace('<code>', '<pre>')
        text = text.replace('</code>', '</pre>')

        text = wikimarkup.to_unicode(text)
        text = self.strip(text)

        text = super(WikiParser, self).parse(text)
        text = self.addImage(text, id)
        text = self.attachDoc(text, id)
        text = self.recordLink(text)
        text = self.viewRecordLink(text)
        text = self.addInternalLinks(text)
        #TODO : already implemented but we will implement it later after releasing the 5.0
        #text = self.addRss(text, id)
        return text
Ejemplo n.º 4
0
    def parse(self, text):
        #print "Running subclassed parser!"
        utf8 = isinstance(text, str)
        text = wikimarkup.to_unicode(text)
        if text[-1:] != u'\n':
            text = text + u'\n'
            taggedNewline = True
        else:
            taggedNewline = False

        text = self.strip(text)
        text = self.removeHtmlTags(text)
        text = self.doTableStuff(text)
        text = self.parseHorizontalRule(text)
        text = self.checkTOC(text)
        text = self.parseHeaders(text)
        text = self.parseAllQuotes(text)
        text = self.replaceExternalLinks(text)
        if not self.show_toc and text.find(u"<!--MWTOC-->") == -1:
            self.show_toc = False
        text = self.formatHeadings(text, True)
        text = self.unstrip(text)
        text = self.fixtags(text)
        text = self.replaceRedirect(text)
        text = self.doBlockLevels(text, True)
        text = self.unstripNoWiki(text)
        text = self.replaceImageLinks(text)
        text = self.replaceCategories(text)
        text = self.replaceAuthorLinks(text)
        text = self.replaceWikiLinks(text)
        text = self.removeTemplates(text)

        text = text.split(u'\n')
        text = u'\n'.join(text)
        if taggedNewline and text[-1:] == u'\n':
            text = text[:-1]
        if utf8:
            return text.encode("utf-8")
        return text
Ejemplo n.º 5
0
    def parse(self,text):
        #print "Running subclassed parser!"
        utf8 = isinstance(text, str)
        text = wikimarkup.to_unicode(text)
        if text[-1:] != u'\n':
            text = text + u'\n'
            taggedNewline = True
        else:
            taggedNewline = False

        text = self.strip(text)
        text = self.removeHtmlTags(text)
        text = self.doTableStuff(text)
        text = self.parseHorizontalRule(text)
        text = self.checkTOC(text)
        text = self.parseHeaders(text)
        text = self.parseAllQuotes(text)
        text = self.replaceExternalLinks(text)
        if not self.show_toc and text.find(u"<!--MWTOC-->") == -1:
            self.show_toc = False
        text = self.formatHeadings(text, True)
        text = self.unstrip(text)
        text = self.fixtags(text)
        text = self.replaceRedirect(text)
        text = self.doBlockLevels(text, True)
        text = self.unstripNoWiki(text)
        text = self.replaceImageLinks(text)
        text = self.replaceCategories(text) 
        text = self.replaceAuthorLinks(text) 
        text = self.replaceWikiLinks(text)
        text = self.removeTemplates(text)

        text = text.split(u'\n')
        text = u'\n'.join(text)
        if taggedNewline and text[-1:] == u'\n':
            text = text[:-1]
        if utf8:
            return text.encode("utf-8")
        return text