Esempio n. 1
0
    def parse_marked_section(self, i, report=1):
        try:
            from markupbase import _markedsectionclose, _msmarkedsectionclose
        except ImportError:
            from _markupbase import _markedsectionclose, _msmarkedsectionclose

        rawdata= self.rawdata
        assert rawdata[i:i+3] == '<![', "unexpected call to parse_marked_section()"
        sectName, j = self._scan_name( i+3, i )
        if j < 0:
            return j
        if sectName in ("temp", "cdata", "ignore", "include", "rcdata"):
            # look for standard ]]> ending
            match= _markedsectionclose.search(rawdata, i+3)
        elif sectName in ("if", "else", "endif"):
            # look for MS Office ]> ending
            match= _msmarkedsectionclose.search(rawdata, i+3)
        else:
            self.error('unknown status keyword %r in marked section' % rawdata[i+3:j])
        if not match:
            return -1
        if report:
            if sectName == "cdata":
                assert rawdata[j] == '['
                self.handle_data(rawdata[j+1:match.start(0)])
            else:
                j = match.start(0)
                self.unknown_decl(rawdata[i+3: j])
        return match.end(0)
Esempio n. 2
0
 def parse_marked_section(self, i, report=1):
     from markupbase import _markedsectionclose, _msmarkedsectionclose
     rawdata = self.rawdata
     assert rawdata[i:i +
                    3] == '<![', "unexpected call to parse_marked_section()"
     sectName, j = self._scan_name(i + 3, i)
     if j < 0:
         return j
     if sectName in ("temp", "cdata", "ignore", "include", "rcdata"):
         # look for standard ]]> ending
         match = _markedsectionclose.search(rawdata, i + 3)
     elif sectName in ("if", "else", "endif"):
         # look for MS Office ]> ending
         match = _msmarkedsectionclose.search(rawdata, i + 3)
     else:
         self.error('unknown status keyword %r in marked section' %
                    rawdata[i + 3:j])
     if not match:
         return -1
     if report:
         if sectName == "cdata":
             assert rawdata[j] == '['
             self.handle_data(rawdata[j + 1:match.start(0)])
         else:
             j = match.start(0)
             self.unknown_decl(rawdata[i + 3:j])
     return match.end(0)