reportlab/platypus/paraparser.py
changeset 2664 c9faa3a99e93
parent 2663 927cc273c5a5
child 2670 3fdd642a7b76
equal deleted inserted replaced
2663:927cc273c5a5 2664:c9faa3a99e93
   463             except:
   463             except:
   464                 self._syntax_error('<unichar/> invalid code attribute %s' % attr['code'])
   464                 self._syntax_error('<unichar/> invalid code attribute %s' % attr['code'])
   465                 v = '\0'
   465                 v = '\0'
   466         else:
   466         else:
   467             v = None
   467             v = None
   468             if attr: 
   468             if attr:
   469                 self._syntax_error('<unichar/> invalid attribute %s' % attr.keys()[0])
   469                 self._syntax_error('<unichar/> invalid attribute %s' % attr.keys()[0])
   470 
   470 
   471         if v is not None:
   471         if v is not None:
   472             self.handle_data(v)
   472             self.handle_data(v)
   473         self._push(_selfClosingTag='unichar')
   473         self._push(_selfClosingTag='unichar')
   481     def end_font(self):
   481     def end_font(self):
   482         self._pop()
   482         self._pop()
   483 
   483 
   484     def start_br(self, attr):
   484     def start_br(self, attr):
   485         #just do the trick to make sure there is no content
   485         #just do the trick to make sure there is no content
   486         self._push(_selfClosingTag='br', lineBreak=True, text='')
   486         self._push(_selfClosingTag='br',lineBreak=True,text='')
   487 
   487 
   488     def end_br(self):
   488     def end_br(self):
   489         frag = self._pop(_selfClosingTag='br', lineBreak=True)
   489         frag = self._stack[-1]
   490         self.fragList.append(frag)
   490         assert frag._selfClosingTag=='br' and frag.lineBreak,'Parser failure in <br/>'
   491 
   491         del frag._selfClosingTag
       
   492         self.handle_data('')
       
   493         self._pop()
   492 
   494 
   493     def _initial_frag(self,attr,attrMap,bullet=0):
   495     def _initial_frag(self,attr,attrMap,bullet=0):
   494         style = self._style
   496         style = self._style
   495         if attr!={}:
   497         if attr!={}:
   496             style = copy.deepcopy(style)
   498             style = copy.deepcopy(style)
   758                 for frag in fragList:
   760                 for frag in fragList:
   759                     frag.text = unicode(frag.text, self._enc)
   761                     frag.text = unicode(frag.text, self._enc)
   760             if bFragList:
   762             if bFragList:
   761                 for frag in bFragList:
   763                 for frag in bFragList:
   762                     frag.text = unicode(frag.text, self._enc)
   764                     frag.text = unicode(frag.text, self._enc)
   763             
   765 
   764         return style, fragList, bFragList
   766         return style, fragList, bFragList
   765 
   767 
   766     def _tt_parse(self,tt):
   768     def _tt_parse(self,tt):
   767         tag = tt[0]
   769         tag = tt[0]
   768         try:
   770         try:
   915     check_text('''Here comes <FONT FACE="Helvetica" SIZE="14pt">Helvetica 14</FONT> with <STRONG>strong</STRONG> <EM>emphasis</EM>.''')
   917     check_text('''Here comes <FONT FACE="Helvetica" SIZE="14pt">Helvetica 14</FONT> with <STRONG>strong</STRONG> <EM>emphasis</EM>.''')
   916     check_text('''Here comes <font face="Helvetica" size="14pt">Helvetica 14</font> with <Strong>strong</Strong> <em>emphasis</em>.''')
   918     check_text('''Here comes <font face="Helvetica" size="14pt">Helvetica 14</font> with <Strong>strong</Strong> <em>emphasis</em>.''')
   917     check_text('''Here comes <font face="Courier" size="3cm">Courier 3cm</font> and normal again.''')
   919     check_text('''Here comes <font face="Courier" size="3cm">Courier 3cm</font> and normal again.''')
   918     #AR 14-Jul-2006: test <br/> tag
   920     #AR 14-Jul-2006: test <br/> tag
   919     check_text('''Before the break <br/>the middle line <br/> and the last line.''')
   921     check_text('''Before the break <br/>the middle line <br/> and the last line.''')
   920     
   922