reportlab/platypus/paraparser.py
changeset 1736 dafc17db33d2
parent 1683 7fa753e4420a
child 1931 784fce255e2d
equal deleted inserted replaced
1735:08bc12b1fcfe 1736:dafc17db33d2
     1 #copyright ReportLab Inc. 2000
     1 #copyright ReportLab Inc. 2000
     2 #see license.txt for license details
     2 #see license.txt for license details
     3 #history http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/reportlab/platypus/paraparser.py?cvsroot=reportlab
     3 #history http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/reportlab/platypus/paraparser.py?cvsroot=reportlab
     4 #$Header: /tmp/reportlab/reportlab/platypus/paraparser.py,v 1.47 2002/07/24 19:56:38 andy_robinson Exp $
     4 #$Header: /tmp/reportlab/reportlab/platypus/paraparser.py,v 1.48 2002/09/30 09:43:03 rgbecker Exp $
     5 __version__=''' $Id: paraparser.py,v 1.47 2002/07/24 19:56:38 andy_robinson Exp $ '''
     5 __version__=''' $Id: paraparser.py,v 1.48 2002/09/30 09:43:03 rgbecker Exp $ '''
     6 import string
     6 import string
     7 import re
     7 import re
     8 from types import TupleType
     8 from types import TupleType
     9 import sys
     9 import sys
    10 import os
    10 import os
   165 # tags:
   165 # tags:
   166 #       < /b > - bold
   166 #       < /b > - bold
   167 #       < /i > - italics
   167 #       < /i > - italics
   168 #       < u > < /u > - underline
   168 #       < u > < /u > - underline
   169 #       < super > < /super > - superscript
   169 #       < super > < /super > - superscript
       
   170 #       < sup > < /sup > - superscript
   170 #       < sub > < /sub > - subscript
   171 #       < sub > < /sub > - subscript
   171 #       <font name=fontfamily/fontname color=colorname size=float>
   172 #       <font name=fontfamily/fontname color=colorname size=float>
   172 #       < bullet > </bullet> - bullet text (at head of para only)
   173 #       < bullet > </bullet> - bullet text (at head of para only)
   173 #       <onDraw name=callable label="a label">
   174 #       <onDraw name=callable label="a label">
   174 #
   175 #
   217     def start_super( self, attributes ):
   218     def start_super( self, attributes ):
   218         self._push(super=1)
   219         self._push(super=1)
   219 
   220 
   220     def end_super( self ):
   221     def end_super( self ):
   221         self._pop(super=1)
   222         self._pop(super=1)
       
   223 
       
   224     if _xmllib_newStyle:
       
   225         start_sup = start_super
       
   226         end_sup = end_super
   222 
   227 
   223     #### sub script
   228     #### sub script
   224     def start_sub( self, attributes ):
   229     def start_sub( self, attributes ):
   225         self._push(sub=1)
   230         self._push(sub=1)
   226 
   231 
   414             # set up handlers for various tags
   419             # set up handlers for various tags
   415             self.elements = {   'b': (self.start_b, self.end_b),
   420             self.elements = {   'b': (self.start_b, self.end_b),
   416                             'u': (self.start_u, self.end_u),
   421                             'u': (self.start_u, self.end_u),
   417                             'i': (self.start_i, self.end_i),
   422                             'i': (self.start_i, self.end_i),
   418                             'super': (self.start_super, self.end_super),
   423                             'super': (self.start_super, self.end_super),
       
   424                             'sup': (self.start_super, self.end_super),
   419                             'sub': (self.start_sub, self.end_sub),
   425                             'sub': (self.start_sub, self.end_sub),
   420                             'font': (self.start_font, self.end_font),
   426                             'font': (self.start_font, self.end_font),
   421                             'greek': (self.start_greek, self.end_greek),
   427                             'greek': (self.start_greek, self.end_greek),
   422                             'para': (self.start_para, self.end_para)
   428                             'para': (self.start_para, self.end_para)
   423                             }
   429                             }
   454 
   460 
   455         frag = copy.copy(self._stack[-1])
   461         frag = copy.copy(self._stack[-1])
   456         if hasattr(frag,'cbDefn'):
   462         if hasattr(frag,'cbDefn'):
   457             if data!='': syntax_error('Only <onDraw> tag allowed')
   463             if data!='': syntax_error('Only <onDraw> tag allowed')
   458         else:
   464         else:
   459             # if sub and super are both one they will cancel each other out
   465             # if sub and super are both on they will cancel each other out
   460             if frag.sub == 1 and frag.super == 1:
   466             if frag.sub == 1 and frag.super == 1:
   461                 frag.sub = 0
   467                 frag.sub = 0
   462                 frag.super = 0
   468                 frag.super = 0
   463 
   469 
   464             if frag.sub:
   470             if frag.sub: