예제 #1
0
 def tohtml(self):
     begintag = {
         BT_HEADCELL: '<th ',
         BT_HEADCELLSTYLE: '<th ',
         BT_CELL: '<td ',
         BT_CELLSTYLE: '<td '
     }
     endtag = {
         BT_HEADCELL: '</th>',
         BT_HEADCELLSTYLE: '</th>',
         BT_CELL: '</td>',
         BT_CELLSTYLE: '</td>'
     }
     htmlcells = []
     for props, cmrkup, cell, nl, type in self.cells:
         d_style, s_style = split_style(props)
         style = '; '.join([ k + ' : ' + d_style[k] for k in d_style ]) + \
                 '; ' + s_style
         contents = []
         if isinstance(cell, TextContents):
             [contents.extend(item.contents) for item in cell.textcontents]
         process_textcontent(contents)
         htmlcells.append(
                 begintag[type] + 'style="' + style + '">' + \
                 cell.tohtml() + endtag[type]
         )
     return ''.join(htmlcells)
예제 #2
0
 def tohtml(self):
     html = ''
     if not self.skip:
         d_style, s_style = split_style(self.trow_props)
         trowstyle = '; '.join([ k + ' : ' + d_style[k] for k in d_style ]) + \
                     '; ' + s_style
         html = '<tr ' + 'style="' + trowstyle + ';">' + \
                self.cells.tohtml() + '</tr>'
     return html
예제 #3
0
파일: zwast.py 프로젝트: prataprc/eazytext
 def tohtml( self ) :
     html = ''
     if not self.skip :
         d_style, s_style = split_style( self.trow_props )
         trowstyle = '; '.join([ k + ' : ' + d_style[k] for k in d_style ]) + \
                     '; ' + s_style
         html = '<tr ' + 'style="' + trowstyle + ';">' + \
                self.cells.tohtml() + '</tr>'
     return html
예제 #4
0
    def parse(self, text, filename='', debuglevel=0):
        """Parses C code and returns an AST.
        
        text:
            A string containing the Wiki text
        
        filename:
            Name of the file being parsed (for meaningful error messages)
        
        debuglevel:
            Debug level to yacc"""

        # Initialize
        self.zwlex.filename = filename
        self.zwlex.reset_lineno()
        self.redirect = None
        self.text = text
        self.wiki_css = {}
        self.macroobjects = []  # ZWMacro objects detected while parsing
        self.zwextobjects = []  # ZWExtension objects detected while parsing
        self.predivs = []  # <div> elements prepend before wikipage
        self.postdivs = []  # <div> elements append after wikipage

        d_style, s_style = split_style(self.style)
        d_style and self.wiki_css.update(d_style)
        self.style = s_style or ''
        if not d_style and not s_style:
            self.wiki_css.update(wiki_css)

        props, text = self._wiki_properties(text)
        d_style, s_style = split_style(props)
        d_style and self.wiki_css.update(d_style)
        if s_style:
            self.style += '; ' + s_style + '; '

        # Pre-process the text.
        self.pptext = self.wiki_preprocess(text)

        # parse and get the Translation Unit
        self.pptext += '\n' + ENDMARKER
        self.tu = self.parser.parse(self.pptext,
                                    lexer=self.zwlex,
                                    debug=debuglevel)
        return self.tu
예제 #5
0
 def tohtml(self):
     d_style, s_style = split_style(self.table_props)
     tblstyle = '; '.join([ k + ' : ' + d_style[k] for k in d_style ]) + \
                '; ' + s_style
     html     = '<table border="' + self.border + '" cellspacing="' + \
                        self.cellspacing + '" cellpadding="' + \
                        self.cellpadding + '" style="' + tblstyle + ';">'
     if self.caption:
         html += "<caption>" + self.caption + "</caption>"
     html += self.rows.tohtml() + '</table>'
     return html
예제 #6
0
파일: zwast.py 프로젝트: prataprc/eazytext
 def tohtml( self ) :
     d_style, s_style = split_style( self.table_props )
     tblstyle = '; '.join([ k + ' : ' + d_style[k] for k in d_style ]) + \
                '; ' + s_style
     html     = '<table border="' + self.border + '" cellspacing="' + \
                        self.cellspacing + '" cellpadding="' + \
                        self.cellpadding + '" style="' + tblstyle + ';">'
     if self.caption :
         html += "<caption>" + self.caption + "</caption>"
     html += self.rows.tohtml() + '</table>'
     return html
예제 #7
0
파일: zwast.py 프로젝트: prataprc/eazytext
 def tohtml( self ) :
     begintag = { BT_HEADCELL : '<th ', BT_HEADCELLSTYLE : '<th ',
                  BT_CELL     : '<td ', BT_CELLSTYLE     : '<td '
                }
     endtag   = { BT_HEADCELL : '</th>', BT_HEADCELLSTYLE : '</th>',
                  BT_CELL     : '</td>', BT_CELLSTYLE     : '</td>'
                }
     htmlcells = []
     for props, cmrkup, cell, nl, type in self.cells :
         d_style, s_style = split_style( props )
         style = '; '.join([ k + ' : ' + d_style[k] for k in d_style ]) + \
                 '; ' + s_style
         contents = []
         if isinstance( cell, TextContents ) :
             [ contents.extend(item.contents) for item in cell.textcontents ]
         process_textcontent( contents )
         htmlcells.append( 
                 begintag[type] + 'style="' + style + '">' + \
                 cell.tohtml() + endtag[type] 
         )
     return ''.join( htmlcells )