src/reportlab/platypus/paraparser.py
author rptlab
Tue, 30 Apr 2013 14:28:14 +0100
branchpy33
changeset 3723 99aa837b6703
parent 3721 0c93dd8ff567
child 3731 b233dd0577ff
permissions -rw-r--r--
second stage of port to Python 3.3; working hello world
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3617
ae5744e97c42 reportlab: copyright date changes
robin
parents: 3552
diff changeset
     1
#Copyright ReportLab Europe Ltd. 2000-2012
494
54257447cfe9 Changed to indirect copyright
rgbecker
parents: 433
diff changeset
     2
#see license.txt for license details
2332
2a7ab4405e18 Remove $Header:, fix CopyRight & history
rgbecker
parents: 2321
diff changeset
     3
#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/platypus/paraparser.py
2321
3454f5b41760 Unicode and UTF8 support changes
andy
parents: 2200
diff changeset
     4
__version__=''' $Id$ '''
3032
22224b1b4d24 New docstrings mainly for module titles
damian
parents: 2964
diff changeset
     5
__doc__='''The parser used to process markup within paragraphs'''
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
     6
import string
119
b4dc589c8364 <para> tag added in layout.py paraparser.py
rgbecker
parents: 115
diff changeset
     7
import re
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
     8
from types import TupleType, UnicodeType, StringType
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
     9
import sys
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
    10
import os
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
    11
import copy
3187
2d5a6655556e tableofcontents/paraparser: allow for format and offset parameters
rgbecker
parents: 3165
diff changeset
    12
import base64
2d5a6655556e tableofcontents/paraparser: allow for format and offset parameters
rgbecker
parents: 3165
diff changeset
    13
try:
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3656
diff changeset
    14
    import pickle as pickle
3187
2d5a6655556e tableofcontents/paraparser: allow for format and offset parameters
rgbecker
parents: 3165
diff changeset
    15
except:
2d5a6655556e tableofcontents/paraparser: allow for format and offset parameters
rgbecker
parents: 3165
diff changeset
    16
    import pickle
2693
3c61a57aecd1 missing import statement
andy
parents: 2670
diff changeset
    17
import unicodedata
279
e7d8b3631d5c Global sequencer put in the 'story builder'.
andy_robinson
parents: 267
diff changeset
    18
import reportlab.lib.sequencer
518
5be3fcb26c78 Semantic Name changes
rgbecker
parents: 514
diff changeset
    19
from reportlab.lib.abag import ABag
2857
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    20
from reportlab.lib.utils import ImageReader
1160
2cb58079d830 Removed Aaron's rather thoughtless hacks
rgbecker
parents: 1156
diff changeset
    21
2376
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
    22
from reportlab.lib import xmllib
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
    23
248
c103b7a55e79 Color fixes; thanks to J Alet
rgbecker
parents: 238
diff changeset
    24
from reportlab.lib.colors import toColor, white, black, red, Color
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
    25
from reportlab.lib.fonts import tt2ps, ps2tt
119
b4dc589c8364 <para> tag added in layout.py paraparser.py
rgbecker
parents: 115
diff changeset
    26
from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY
1940
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
    27
from reportlab.lib.units import inch,mm,cm,pica
2410
f505ed647678 reportlab: add fix for <para/> and new test
rgbecker
parents: 2376
diff changeset
    28
_re_para = re.compile(r'^\s*<\s*para(?:\s+|>|/>)')
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
    29
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
    30
sizeDelta = 2       # amount to reduce font size by for super and sub script
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
    31
subFraction = 0.5   # fraction of font size that a sub script should be lowered
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
    32
superFraction = 0.5 # fraction of font size that a super script should be raised
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
    33
3165
cbda9e7d0ee3 reportlab: new index support
rgbecker
parents: 3137
diff changeset
    34
DEFAULT_INDEX_NAME='_indexAdd'
cbda9e7d0ee3 reportlab: new index support
rgbecker
parents: 3137
diff changeset
    35
2857
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    36
3434
3c14212cc997 platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents: 3368
diff changeset
    37
def _convnum(s, unit=1, allowRelative=True):
3c14212cc997 platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents: 3368
diff changeset
    38
    if s[0] in ('+','-') and allowRelative:
2857
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    39
        try:
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    40
            return ('relative',int(s)*unit)
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    41
        except ValueError:
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    42
            return ('relative',float(s)*unit)
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    43
    else:
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    44
        try:
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    45
            return int(s)*unit
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    46
        except ValueError:
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    47
            return float(s)*unit
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    48
3434
3c14212cc997 platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents: 3368
diff changeset
    49
def _num(s, unit=1, allowRelative=True):
1940
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
    50
    """Convert a string like '10cm' to an int or float (in points).
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
    51
       The default unit is point, but optionally you can use other
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
    52
       default units like mm.
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
    53
    """
3434
3c14212cc997 platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents: 3368
diff changeset
    54
    if s.endswith('cm'):
1940
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
    55
        unit=cm
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
    56
        s = s[:-2]
3434
3c14212cc997 platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents: 3368
diff changeset
    57
    if s.endswith('in'):
1940
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
    58
        unit=inch
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
    59
        s = s[:-2]
3434
3c14212cc997 platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents: 3368
diff changeset
    60
    if s.endswith('pt'):
1940
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
    61
        unit=1
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
    62
        s = s[:-2]
3434
3c14212cc997 platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents: 3368
diff changeset
    63
    if s.endswith('i'):
1940
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
    64
        unit=inch
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
    65
        s = s[:-1]
3434
3c14212cc997 platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents: 3368
diff changeset
    66
    if s.endswith('mm'):
1940
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
    67
        unit=mm
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
    68
        s = s[:-2]
3434
3c14212cc997 platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents: 3368
diff changeset
    69
    if s.endswith('pica'):
1940
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
    70
        unit=pica
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
    71
        s = s[:-4]
3434
3c14212cc997 platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents: 3368
diff changeset
    72
    return _convnum(s,unit,allowRelative)
3c14212cc997 platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents: 3368
diff changeset
    73
3c14212cc997 platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents: 3368
diff changeset
    74
def _numpct(s,unit=1,allowRelative=False):
3c14212cc997 platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents: 3368
diff changeset
    75
    if s.endswith('%'):
3c14212cc997 platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents: 3368
diff changeset
    76
        return _PCT(_convnum(s[:-1],allowRelative=allowRelative))
3c14212cc997 platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents: 3368
diff changeset
    77
    else:
3c14212cc997 platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents: 3368
diff changeset
    78
        return _num(s,unit,allowRelative)
2857
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    79
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    80
class _PCT:
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    81
    def __init__(self,v):
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    82
        self._value = v*0.01
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    83
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    84
    def normalizedValue(self,normalizer):
3434
3c14212cc997 platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents: 3368
diff changeset
    85
        normalizer = normalizer or getattr(self,'_normalizer')
2857
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    86
        return normalizer*self._value
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    87
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    88
def _valignpc(s):
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    89
    s = s.lower()
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    90
    if s in ('baseline','sub','super','top','text-top','middle','bottom','text-bottom'):
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    91
        return s
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    92
    if s.endswith('%'):
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    93
        n = _convnum(s[:-1])
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    94
        if isinstance(n,tuple):
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    95
            n = n[1]
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    96
        return _PCT(n)
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    97
    n = _num(s)
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    98
    if isinstance(n,tuple):
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
    99
        n = n[1]
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
   100
    return n
119
b4dc589c8364 <para> tag added in layout.py paraparser.py
rgbecker
parents: 115
diff changeset
   101
2836
66fb84201abe platypus: add support for autoLeading
rgbecker
parents: 2748
diff changeset
   102
def _autoLeading(x):
66fb84201abe platypus: add support for autoLeading
rgbecker
parents: 2748
diff changeset
   103
    x = x.lower()
66fb84201abe platypus: add support for autoLeading
rgbecker
parents: 2748
diff changeset
   104
    if x in ('','min','max','off'):
66fb84201abe platypus: add support for autoLeading
rgbecker
parents: 2748
diff changeset
   105
        return x
66fb84201abe platypus: add support for autoLeading
rgbecker
parents: 2748
diff changeset
   106
    raise ValueError('Invalid autoLeading=%r' % x )
66fb84201abe platypus: add support for autoLeading
rgbecker
parents: 2748
diff changeset
   107
119
b4dc589c8364 <para> tag added in layout.py paraparser.py
rgbecker
parents: 115
diff changeset
   108
def _align(s):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   109
    s = string.lower(s)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   110
    if s=='left': return TA_LEFT
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   111
    elif s=='right': return TA_RIGHT
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   112
    elif s=='justify': return TA_JUSTIFY
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   113
    elif s in ('centre','center'): return TA_CENTER
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   114
    else: raise ValueError
119
b4dc589c8364 <para> tag added in layout.py paraparser.py
rgbecker
parents: 115
diff changeset
   115
b4dc589c8364 <para> tag added in layout.py paraparser.py
rgbecker
parents: 115
diff changeset
   116
_paraAttrMap = {'font': ('fontName', None),
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   117
                'face': ('fontName', None),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   118
                'fontsize': ('fontSize', _num),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   119
                'size': ('fontSize', _num),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   120
                'leading': ('leading', _num),
2836
66fb84201abe platypus: add support for autoLeading
rgbecker
parents: 2748
diff changeset
   121
                'autoleading': ('autoLeading', _autoLeading),
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   122
                'lindent': ('leftIndent', _num),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   123
                'rindent': ('rightIndent', _num),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   124
                'findent': ('firstLineIndent', _num),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   125
                'align': ('alignment', _align),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   126
                'spaceb': ('spaceBefore', _num),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   127
                'spacea': ('spaceAfter', _num),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   128
                'bfont': ('bulletFontName', None),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   129
                'bfontsize': ('bulletFontSize',_num),
2860
3f14d66194c2 platypus: added bulletOffsetY inspired by haraldarminmassa@gmail.com
rgbecker
parents: 2857
diff changeset
   130
                'boffsety': ('bulletOffsetY',_num),
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   131
                'bindent': ('bulletIndent',_num),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   132
                'bcolor': ('bulletColor',toColor),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   133
                'color':('textColor',toColor),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   134
                'backcolor':('backColor',toColor),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   135
                'bgcolor':('backColor',toColor),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   136
                'bg':('backColor',toColor),
1940
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
   137
                'fg': ('textColor',toColor),
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
   138
                }
119
b4dc589c8364 <para> tag added in layout.py paraparser.py
rgbecker
parents: 115
diff changeset
   139
250
a1bcf9c6c21e <bullet> xml tag added
rgbecker
parents: 248
diff changeset
   140
_bulletAttrMap = {
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   141
                'font': ('bulletFontName', None),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   142
                'face': ('bulletFontName', None),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   143
                'size': ('bulletFontSize',_num),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   144
                'fontsize': ('bulletFontSize',_num),
2860
3f14d66194c2 platypus: added bulletOffsetY inspired by haraldarminmassa@gmail.com
rgbecker
parents: 2857
diff changeset
   145
                'offsety': ('bulletOffsetY',_num),
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   146
                'indent': ('bulletIndent',_num),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   147
                'color': ('bulletColor',toColor),
1940
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
   148
                'fg': ('bulletColor',toColor),
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
   149
                }
250
a1bcf9c6c21e <bullet> xml tag added
rgbecker
parents: 248
diff changeset
   150
119
b4dc589c8364 <para> tag added in layout.py paraparser.py
rgbecker
parents: 115
diff changeset
   151
#things which are valid font attributes
b4dc589c8364 <para> tag added in layout.py paraparser.py
rgbecker
parents: 115
diff changeset
   152
_fontAttrMap = {'size': ('fontSize', _num),
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   153
                'face': ('fontName', None),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   154
                'name': ('fontName', None),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   155
                'fg':   ('textColor', toColor),
1940
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
   156
                'color':('textColor', toColor),
2446
6b9268ab33c3 allow solid para background
andy
parents: 2410
diff changeset
   157
                'backcolor':('backColor',toColor),
6b9268ab33c3 allow solid para background
andy
parents: 2410
diff changeset
   158
                'bgcolor':('backColor',toColor),
1940
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
   159
                }
3552
20ecbcc53c15 paraparser.py add support for <span style=stylename>
rgbecker
parents: 3440
diff changeset
   160
#things which are valid span attributes
20ecbcc53c15 paraparser.py add support for <span style=stylename>
rgbecker
parents: 3440
diff changeset
   161
_spanAttrMap = {'size': ('fontSize', _num),
20ecbcc53c15 paraparser.py add support for <span style=stylename>
rgbecker
parents: 3440
diff changeset
   162
                'face': ('fontName', None),
20ecbcc53c15 paraparser.py add support for <span style=stylename>
rgbecker
parents: 3440
diff changeset
   163
                'name': ('fontName', None),
20ecbcc53c15 paraparser.py add support for <span style=stylename>
rgbecker
parents: 3440
diff changeset
   164
                'fg':   ('textColor', toColor),
20ecbcc53c15 paraparser.py add support for <span style=stylename>
rgbecker
parents: 3440
diff changeset
   165
                'color':('textColor', toColor),
20ecbcc53c15 paraparser.py add support for <span style=stylename>
rgbecker
parents: 3440
diff changeset
   166
                'backcolor':('backColor',toColor),
20ecbcc53c15 paraparser.py add support for <span style=stylename>
rgbecker
parents: 3440
diff changeset
   167
                'bgcolor':('backColor',toColor),
20ecbcc53c15 paraparser.py add support for <span style=stylename>
rgbecker
parents: 3440
diff changeset
   168
                'style': ('style',None),
20ecbcc53c15 paraparser.py add support for <span style=stylename>
rgbecker
parents: 3440
diff changeset
   169
                }
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   170
#things which are valid font attributes
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   171
_linkAttrMap = {'size': ('fontSize', _num),
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   172
                'face': ('fontName', None),
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   173
                'name': ('fontName', None),
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   174
                'fg':   ('textColor', toColor),
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   175
                'color':('textColor', toColor),
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   176
                'backcolor':('backColor',toColor),
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   177
                'bgcolor':('backColor',toColor),
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   178
                'dest': ('link', None),
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   179
                'destination': ('link', None),
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   180
                'target': ('link', None),
2594
746800f5caf9 reportlab: fix up links in paragraphs
rgbecker
parents: 2585
diff changeset
   181
                'href': ('link', None),
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   182
                }
2744
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   183
_anchorAttrMap = {'fontSize': ('fontSize', _num),
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   184
                'fontName': ('fontName', None),
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   185
                'name': ('name', None),
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   186
                'fg':   ('textColor', toColor),
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   187
                'color':('textColor', toColor),
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   188
                'backcolor':('backColor',toColor),
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   189
                'bgcolor':('backColor',toColor),
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   190
                'href': ('href', None),
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   191
                }
2857
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
   192
_imgAttrMap = {
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
   193
                'src': ('src', None),
3434
3c14212cc997 platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents: 3368
diff changeset
   194
                'width': ('width',_numpct),
3c14212cc997 platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents: 3368
diff changeset
   195
                'height':('height',_numpct),
2857
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
   196
                'valign':('valign',_valignpc),
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
   197
                }
3165
cbda9e7d0ee3 reportlab: new index support
rgbecker
parents: 3137
diff changeset
   198
_indexAttrMap = {
cbda9e7d0ee3 reportlab: new index support
rgbecker
parents: 3137
diff changeset
   199
                'name': ('name',None),
cbda9e7d0ee3 reportlab: new index support
rgbecker
parents: 3137
diff changeset
   200
                'item': ('item',None),
3187
2d5a6655556e tableofcontents/paraparser: allow for format and offset parameters
rgbecker
parents: 3165
diff changeset
   201
                'offset': ('offset',None),
2d5a6655556e tableofcontents/paraparser: allow for format and offset parameters
rgbecker
parents: 3165
diff changeset
   202
                'format': ('format',None),
3165
cbda9e7d0ee3 reportlab: new index support
rgbecker
parents: 3137
diff changeset
   203
                }
119
b4dc589c8364 <para> tag added in layout.py paraparser.py
rgbecker
parents: 115
diff changeset
   204
b4dc589c8364 <para> tag added in layout.py paraparser.py
rgbecker
parents: 115
diff changeset
   205
def _addAttributeNames(m):
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3656
diff changeset
   206
    K = list(m.keys())
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   207
    for k in K:
1944
a50f8e3f93f8 laissez faire case
rgbecker
parents: 1940
diff changeset
   208
        n = m[k][0]
3326
ce725978d11c Initial Python3 compatibility fixes
damian
parents: 3188
diff changeset
   209
        if n not in m: m[n] = m[k]
1944
a50f8e3f93f8 laissez faire case
rgbecker
parents: 1940
diff changeset
   210
        n = string.lower(n)
3326
ce725978d11c Initial Python3 compatibility fixes
damian
parents: 3188
diff changeset
   211
        if n not in m: m[n] = m[k]
119
b4dc589c8364 <para> tag added in layout.py paraparser.py
rgbecker
parents: 115
diff changeset
   212
b4dc589c8364 <para> tag added in layout.py paraparser.py
rgbecker
parents: 115
diff changeset
   213
_addAttributeNames(_paraAttrMap)
b4dc589c8364 <para> tag added in layout.py paraparser.py
rgbecker
parents: 115
diff changeset
   214
_addAttributeNames(_fontAttrMap)
3552
20ecbcc53c15 paraparser.py add support for <span style=stylename>
rgbecker
parents: 3440
diff changeset
   215
_addAttributeNames(_spanAttrMap)
250
a1bcf9c6c21e <bullet> xml tag added
rgbecker
parents: 248
diff changeset
   216
_addAttributeNames(_bulletAttrMap)
2747
46005202d9d0 paraparser: fix link/anchor attributes
rgbecker
parents: 2745
diff changeset
   217
_addAttributeNames(_anchorAttrMap)
46005202d9d0 paraparser: fix link/anchor attributes
rgbecker
parents: 2745
diff changeset
   218
_addAttributeNames(_linkAttrMap)
119
b4dc589c8364 <para> tag added in layout.py paraparser.py
rgbecker
parents: 115
diff changeset
   219
b4dc589c8364 <para> tag added in layout.py paraparser.py
rgbecker
parents: 115
diff changeset
   220
def _applyAttributes(obj, attr):
3723
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   221
    for k, v in attr.items():
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   222
        if type(v) is TupleType and v[0]=='relative':
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   223
            #AR 20/5/2000 - remove 1.5.2-ism
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   224
            #v = v[1]+getattr(obj,k,0)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   225
            if hasattr(obj, k):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   226
                v = v[1]+getattr(obj,k)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   227
            else:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   228
                v = v[1]
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   229
        setattr(obj,k,v)
102
1818e7fa3738 Added clone method to ParaFrag
rgbecker
parents: 96
diff changeset
   230
1931
784fce255e2d Added in more special entities as suggested by Christoph Zwerschke
rgbecker
parents: 1736
diff changeset
   231
#Named character entities intended to be supported from the special font
2200
be0cfccc662a Fixed up tabs and whitespace in all source files
andy_robinson
parents: 2053
diff changeset
   232
#with additions suggested by Christoph Zwerschke who also suggested the
1931
784fce255e2d Added in more special entities as suggested by Christoph Zwerschke
rgbecker
parents: 1736
diff changeset
   233
#numeric entity names that follow.
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
   234
greeks = {
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   235
    'Aacute': '\xc3\x81',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   236
    'aacute': '\xc3\xa1',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   237
    'Acirc': '\xc3\x82',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   238
    'acirc': '\xc3\xa2',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   239
    'acute': '\xc2\xb4',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   240
    'AElig': '\xc3\x86',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   241
    'aelig': '\xc3\xa6',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   242
    'Agrave': '\xc3\x80',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   243
    'agrave': '\xc3\xa0',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   244
    'alefsym': '\xe2\x84\xb5',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   245
    'Alpha': '\xce\x91',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   246
    'alpha': '\xce\xb1',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   247
    'and': '\xe2\x88\xa7',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   248
    'ang': '\xe2\x88\xa0',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   249
    'Aring': '\xc3\x85',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   250
    'aring': '\xc3\xa5',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   251
    'asymp': '\xe2\x89\x88',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   252
    'Atilde': '\xc3\x83',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   253
    'atilde': '\xc3\xa3',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   254
    'Auml': '\xc3\x84',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   255
    'auml': '\xc3\xa4',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   256
    'bdquo': '\xe2\x80\x9e',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   257
    'Beta': '\xce\x92',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   258
    'beta': '\xce\xb2',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   259
    'brvbar': '\xc2\xa6',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   260
    'bull': '\xe2\x80\xa2',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   261
    'cap': '\xe2\x88\xa9',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   262
    'Ccedil': '\xc3\x87',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   263
    'ccedil': '\xc3\xa7',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   264
    'cedil': '\xc2\xb8',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   265
    'cent': '\xc2\xa2',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   266
    'Chi': '\xce\xa7',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   267
    'chi': '\xcf\x87',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   268
    'circ': '\xcb\x86',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   269
    'clubs': '\xe2\x99\xa3',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   270
    'cong': '\xe2\x89\x85',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   271
    'copy': '\xc2\xa9',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   272
    'crarr': '\xe2\x86\xb5',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   273
    'cup': '\xe2\x88\xaa',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   274
    'curren': '\xc2\xa4',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   275
    'dagger': '\xe2\x80\xa0',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   276
    'Dagger': '\xe2\x80\xa1',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   277
    'darr': '\xe2\x86\x93',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   278
    'dArr': '\xe2\x87\x93',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   279
    'deg': '\xc2\xb0',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   280
    'delta': '\xce\xb4',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   281
    'Delta': '\xe2\x88\x86',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   282
    'diams': '\xe2\x99\xa6',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   283
    'divide': '\xc3\xb7',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   284
    'Eacute': '\xc3\x89',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   285
    'eacute': '\xc3\xa9',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   286
    'Ecirc': '\xc3\x8a',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   287
    'ecirc': '\xc3\xaa',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   288
    'Egrave': '\xc3\x88',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   289
    'egrave': '\xc3\xa8',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   290
    'empty': '\xe2\x88\x85',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   291
    'emsp': '\xe2\x80\x83',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   292
    'ensp': '\xe2\x80\x82',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   293
    'Epsilon': '\xce\x95',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   294
    'epsilon': '\xce\xb5',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   295
    'epsiv': '\xce\xb5',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   296
    'equiv': '\xe2\x89\xa1',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   297
    'Eta': '\xce\x97',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   298
    'eta': '\xce\xb7',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   299
    'ETH': '\xc3\x90',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   300
    'eth': '\xc3\xb0',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   301
    'Euml': '\xc3\x8b',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   302
    'euml': '\xc3\xab',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   303
    'euro': '\xe2\x82\xac',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   304
    'exist': '\xe2\x88\x83',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   305
    'fnof': '\xc6\x92',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   306
    'forall': '\xe2\x88\x80',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   307
    'frac12': '\xc2\xbd',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   308
    'frac14': '\xc2\xbc',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   309
    'frac34': '\xc2\xbe',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   310
    'frasl': '\xe2\x81\x84',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   311
    'Gamma': '\xce\x93',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   312
    'gamma': '\xce\xb3',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   313
    'ge': '\xe2\x89\xa5',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   314
    'harr': '\xe2\x86\x94',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   315
    'hArr': '\xe2\x87\x94',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   316
    'hearts': '\xe2\x99\xa5',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   317
    'hellip': '\xe2\x80\xa6',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   318
    'Iacute': '\xc3\x8d',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   319
    'iacute': '\xc3\xad',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   320
    'Icirc': '\xc3\x8e',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   321
    'icirc': '\xc3\xae',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   322
    'iexcl': '\xc2\xa1',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   323
    'Igrave': '\xc3\x8c',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   324
    'igrave': '\xc3\xac',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   325
    'image': '\xe2\x84\x91',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   326
    'infin': '\xe2\x88\x9e',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   327
    'int': '\xe2\x88\xab',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   328
    'Iota': '\xce\x99',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   329
    'iota': '\xce\xb9',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   330
    'iquest': '\xc2\xbf',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   331
    'isin': '\xe2\x88\x88',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   332
    'Iuml': '\xc3\x8f',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   333
    'iuml': '\xc3\xaf',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   334
    'Kappa': '\xce\x9a',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   335
    'kappa': '\xce\xba',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   336
    'Lambda': '\xce\x9b',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   337
    'lambda': '\xce\xbb',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   338
    'lang': '\xe2\x8c\xa9',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   339
    'laquo': '\xc2\xab',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   340
    'larr': '\xe2\x86\x90',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   341
    'lArr': '\xe2\x87\x90',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   342
    'lceil': '\xef\xa3\xae',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   343
    'ldquo': '\xe2\x80\x9c',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   344
    'le': '\xe2\x89\xa4',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   345
    'lfloor': '\xef\xa3\xb0',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   346
    'lowast': '\xe2\x88\x97',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   347
    'loz': '\xe2\x97\x8a',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   348
    'lrm': '\xe2\x80\x8e',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   349
    'lsaquo': '\xe2\x80\xb9',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   350
    'lsquo': '\xe2\x80\x98',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   351
    'macr': '\xc2\xaf',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   352
    'mdash': '\xe2\x80\x94',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   353
    'micro': '\xc2\xb5',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   354
    'middot': '\xc2\xb7',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   355
    'minus': '\xe2\x88\x92',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   356
    'mu': '\xc2\xb5',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   357
    'Mu': '\xce\x9c',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   358
    'nabla': '\xe2\x88\x87',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   359
    'nbsp': '\xc2\xa0',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   360
    'ndash': '\xe2\x80\x93',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   361
    'ne': '\xe2\x89\xa0',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   362
    'ni': '\xe2\x88\x8b',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   363
    'notin': '\xe2\x88\x89',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   364
    'not': '\xc2\xac',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   365
    'nsub': '\xe2\x8a\x84',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   366
    'Ntilde': '\xc3\x91',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   367
    'ntilde': '\xc3\xb1',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   368
    'Nu': '\xce\x9d',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   369
    'nu': '\xce\xbd',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   370
    'Oacute': '\xc3\x93',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   371
    'oacute': '\xc3\xb3',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   372
    'Ocirc': '\xc3\x94',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   373
    'ocirc': '\xc3\xb4',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   374
    'OElig': '\xc5\x92',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   375
    'oelig': '\xc5\x93',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   376
    'Ograve': '\xc3\x92',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   377
    'ograve': '\xc3\xb2',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   378
    'oline': '\xef\xa3\xa5',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   379
    'omega': '\xcf\x89',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   380
    'Omega': '\xe2\x84\xa6',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   381
    'Omicron': '\xce\x9f',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   382
    'omicron': '\xce\xbf',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   383
    'oplus': '\xe2\x8a\x95',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   384
    'ordf': '\xc2\xaa',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   385
    'ordm': '\xc2\xba',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   386
    'or': '\xe2\x88\xa8',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   387
    'Oslash': '\xc3\x98',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   388
    'oslash': '\xc3\xb8',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   389
    'Otilde': '\xc3\x95',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   390
    'otilde': '\xc3\xb5',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   391
    'otimes': '\xe2\x8a\x97',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   392
    'Ouml': '\xc3\x96',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   393
    'ouml': '\xc3\xb6',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   394
    'para': '\xc2\xb6',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   395
    'part': '\xe2\x88\x82',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   396
    'permil': '\xe2\x80\xb0',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   397
    'perp': '\xe2\x8a\xa5',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   398
    'phis': '\xcf\x86',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   399
    'Phi': '\xce\xa6',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   400
    'phi': '\xcf\x95',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   401
    'piv': '\xcf\x96',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   402
    'Pi': '\xce\xa0',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   403
    'pi': '\xcf\x80',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   404
    'plusmn': '\xc2\xb1',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   405
    'pound': '\xc2\xa3',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   406
    'prime': '\xe2\x80\xb2',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   407
    'Prime': '\xe2\x80\xb3',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   408
    'prod': '\xe2\x88\x8f',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   409
    'prop': '\xe2\x88\x9d',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   410
    'Psi': '\xce\xa8',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   411
    'psi': '\xcf\x88',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   412
    'radic': '\xe2\x88\x9a',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   413
    'rang': '\xe2\x8c\xaa',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   414
    'raquo': '\xc2\xbb',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   415
    'rarr': '\xe2\x86\x92',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   416
    'rArr': '\xe2\x87\x92',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   417
    'rceil': '\xef\xa3\xb9',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   418
    'rdquo': '\xe2\x80\x9d',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   419
    'real': '\xe2\x84\x9c',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   420
    'reg': '\xc2\xae',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   421
    'rfloor': '\xef\xa3\xbb',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   422
    'Rho': '\xce\xa1',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   423
    'rho': '\xcf\x81',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   424
    'rlm': '\xe2\x80\x8f',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   425
    'rsaquo': '\xe2\x80\xba',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   426
    'rsquo': '\xe2\x80\x99',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   427
    'sbquo': '\xe2\x80\x9a',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   428
    'Scaron': '\xc5\xa0',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   429
    'scaron': '\xc5\xa1',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   430
    'sdot': '\xe2\x8b\x85',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   431
    'sect': '\xc2\xa7',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   432
    'shy': '\xc2\xad',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   433
    'sigmaf': '\xcf\x82',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   434
    'sigmav': '\xcf\x82',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   435
    'Sigma': '\xce\xa3',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   436
    'sigma': '\xcf\x83',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   437
    'sim': '\xe2\x88\xbc',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   438
    'spades': '\xe2\x99\xa0',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   439
    'sube': '\xe2\x8a\x86',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   440
    'sub': '\xe2\x8a\x82',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   441
    'sum': '\xe2\x88\x91',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   442
    'sup1': '\xc2\xb9',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   443
    'sup2': '\xc2\xb2',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   444
    'sup3': '\xc2\xb3',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   445
    'supe': '\xe2\x8a\x87',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   446
    'sup': '\xe2\x8a\x83',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   447
    'szlig': '\xc3\x9f',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   448
    'Tau': '\xce\xa4',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   449
    'tau': '\xcf\x84',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   450
    'there4': '\xe2\x88\xb4',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   451
    'thetasym': '\xcf\x91',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   452
    'thetav': '\xcf\x91',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   453
    'Theta': '\xce\x98',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   454
    'theta': '\xce\xb8',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   455
    'thinsp': '\xe2\x80\x89',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   456
    'THORN': '\xc3\x9e',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   457
    'thorn': '\xc3\xbe',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   458
    'tilde': '\xcb\x9c',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   459
    'times': '\xc3\x97',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   460
    'trade': '\xef\xa3\xaa',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   461
    'Uacute': '\xc3\x9a',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   462
    'uacute': '\xc3\xba',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   463
    'uarr': '\xe2\x86\x91',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   464
    'uArr': '\xe2\x87\x91',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   465
    'Ucirc': '\xc3\x9b',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   466
    'ucirc': '\xc3\xbb',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   467
    'Ugrave': '\xc3\x99',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   468
    'ugrave': '\xc3\xb9',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   469
    'uml': '\xc2\xa8',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   470
    'upsih': '\xcf\x92',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   471
    'Upsilon': '\xce\xa5',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   472
    'upsilon': '\xcf\x85',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   473
    'Uuml': '\xc3\x9c',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   474
    'uuml': '\xc3\xbc',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   475
    'weierp': '\xe2\x84\x98',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   476
    'Xi': '\xce\x9e',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   477
    'xi': '\xce\xbe',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   478
    'Yacute': '\xc3\x9d',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   479
    'yacute': '\xc3\xbd',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   480
    'yen': '\xc2\xa5',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   481
    'yuml': '\xc3\xbf',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   482
    'Yuml': '\xc5\xb8',
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   483
    'Zeta': '\xce\x96',
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   484
    'zeta': '\xce\xb6',
3137
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   485
    'zwj': '\xe2\x80\x8d',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   486
    'zwnj': '\xe2\x80\x8c',
a9d20c542ed9 Added missing character entities from rml.dtd.
jonas
parents: 3111
diff changeset
   487
1931
784fce255e2d Added in more special entities as suggested by Christoph Zwerschke
rgbecker
parents: 1736
diff changeset
   488
    }
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
   489
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
   490
#------------------------------------------------------------------------
518
5be3fcb26c78 Semantic Name changes
rgbecker
parents: 514
diff changeset
   491
class ParaFrag(ABag):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   492
    """class ParaFrag contains the intermediate representation of string
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   493
    segments as they are being parsed by the XMLParser.
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   494
    fontname, fontSize, rise, textColor, cbDefn
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   495
    """
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
   496
2584
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   497
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   498
_greek2Utf8=None
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   499
def _greekConvert(data):
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   500
    global _greek2Utf8
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   501
    if not _greek2Utf8:
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   502
        from reportlab.pdfbase.rl_codecs import RL_Codecs
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   503
        import codecs
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3656
diff changeset
   504
        dm = decoding_map = codecs.make_identity_dict(range(32,256))
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3656
diff changeset
   505
        for k in range(0,32):
2584
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   506
            dm[k] = None
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   507
        dm.update(RL_Codecs._RL_Codecs__rl_codecs_data['symbol'][0])
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   508
        _greek2Utf8 = {}
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3656
diff changeset
   509
        for k,v in dm.items():
2584
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   510
            if not v:
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   511
                u = '\0'
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   512
            else:
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3656
diff changeset
   513
                u = chr(v).encode('utf8')
2584
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   514
            _greek2Utf8[chr(k)] = u
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   515
    return ''.join(map(_greek2Utf8.__getitem__,data))
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   516
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
   517
#------------------------------------------------------------------
267
52a348f6c4c3 noted replication of XML markup comment between paraparser.py and paragraph.py
aaron_watters
parents: 266
diff changeset
   518
# !!! NOTE !!! THIS TEXT IS NOW REPLICATED IN PARAGRAPH.PY !!!
2584
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   519
# The ParaFormatter will be able to format the following
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
   520
# tags:
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   521
#       < /b > - bold
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   522
#       < /i > - italics
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   523
#       < u > < /u > - underline
2644
e762ad1c8909 reportlab: add support for strike through
rgbecker
parents: 2594
diff changeset
   524
#       < strike > < /strike > - strike through
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   525
#       < super > < /super > - superscript
1736
dafc17db33d2 Attempt to use sup as well as super
rgbecker
parents: 1683
diff changeset
   526
#       < sup > < /sup > - superscript
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   527
#       < sub > < /sub > - subscript
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   528
#       <font name=fontfamily/fontname color=colorname size=float>
3552
20ecbcc53c15 paraparser.py add support for <span style=stylename>
rgbecker
parents: 3440
diff changeset
   529
#        <span name=fontfamily/fontname color=colorname backcolor=colorname size=float style=stylename>
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   530
#       < bullet > </bullet> - bullet text (at head of para only)
3165
cbda9e7d0ee3 reportlab: new index support
rgbecker
parents: 3137
diff changeset
   531
#       <onDraw name=callable label="a label"/>
cbda9e7d0ee3 reportlab: new index support
rgbecker
parents: 3137
diff changeset
   532
#       <index [name="callablecanvasattribute"] label="a label"/>
2670
3fdd642a7b76 minor cosmetic changes
rgbecker
parents: 2664
diff changeset
   533
#       <link>link text</link>
3fdd642a7b76 minor cosmetic changes
rgbecker
parents: 2664
diff changeset
   534
#           attributes of links 
3fdd642a7b76 minor cosmetic changes
rgbecker
parents: 2664
diff changeset
   535
#               size/fontSize=num
3fdd642a7b76 minor cosmetic changes
rgbecker
parents: 2664
diff changeset
   536
#               name/face/fontName=name
3fdd642a7b76 minor cosmetic changes
rgbecker
parents: 2664
diff changeset
   537
#               fg/textColor/color=color
3fdd642a7b76 minor cosmetic changes
rgbecker
parents: 2664
diff changeset
   538
#               backcolor/backColor/bgcolor=color
3fdd642a7b76 minor cosmetic changes
rgbecker
parents: 2664
diff changeset
   539
#               dest/destination/target/href/link=target
2745
0b44535fa1a5 paraparser/paragraph.py: fix comments
rgbecker
parents: 2744
diff changeset
   540
#       <a>anchor text</a>
2744
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   541
#           attributes of anchors 
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   542
#               fontSize=num
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   543
#               fontName=name
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   544
#               fg/textColor/color=color
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   545
#               backcolor/backColor/bgcolor=color
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   546
#               href=href
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   547
#       <a name="anchorpoint"/>
2584
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   548
#       <unichar name="unicode character name"/>
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   549
#       <unichar value="unicode code point"/>
2857
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
   550
#       <img src="path" width="1in" height="1in" valign="bottom"/>
3440
739ddbe7feab paaraparser/paragraph.py: add info re percentage in <img> for idea contributed by Roberto Alsina <ralsina@netmanagers.com.ar>
rgbecker
parents: 3434
diff changeset
   551
#               width="w%" --> fontSize*w/100   idea from Roberto Alsina
739ddbe7feab paaraparser/paragraph.py: add info re percentage in <img> for idea contributed by Roberto Alsina <ralsina@netmanagers.com.ar>
rgbecker
parents: 3434
diff changeset
   552
#               height="h%" --> linewidth*h/100 <ralsina@netmanagers.com.ar>
2584
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   553
#       <greek> - </greek>
1683
7fa753e4420a Removed all trailing whitespace
andy_robinson
parents: 1677
diff changeset
   554
#
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   555
#       The whole may be surrounded by <para> </para> tags
119
b4dc589c8364 <para> tag added in layout.py paraparser.py
rgbecker
parents: 115
diff changeset
   556
#
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
   557
# It will also be able to handle any MathML specified Greek characters.
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
   558
#------------------------------------------------------------------
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
   559
class ParaParser(xmllib.XMLParser):
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
   560
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   561
    #----------------------------------------------------------
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   562
    # First we will define all of the xml tag handler functions.
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   563
    #
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   564
    # start_<tag>(attributes)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   565
    # end_<tag>()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   566
    #
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   567
    # While parsing the xml ParaFormatter will call these
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   568
    # functions to handle the string formatting tags.
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   569
    # At the start of each tag the corresponding field will
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   570
    # be set to 1 and at the end tag the corresponding field will
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   571
    # be set to 0.  Then when handle_data is called the options
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   572
    # for that data will be aparent by the current settings.
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   573
    #----------------------------------------------------------
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
   574
1940
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
   575
    def __getattr__( self, attrName ):
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
   576
        """This way we can handle <TAG> the same way as <tag> (ignoring case)."""
2369
f3cc620c14ed paraparser.py: minor speedup
rgbecker
parents: 2368
diff changeset
   577
        if attrName!=attrName.lower() and attrName!="caseSensitive" and not self.caseSensitive and \
f3cc620c14ed paraparser.py: minor speedup
rgbecker
parents: 2368
diff changeset
   578
            (attrName.startswith("start_") or attrName.startswith("end_")):
f3cc620c14ed paraparser.py: minor speedup
rgbecker
parents: 2368
diff changeset
   579
                return getattr(self,attrName.lower())
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3656
diff changeset
   580
        raise AttributeError(attrName)
1940
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
   581
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   582
    #### bold
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   583
    def start_b( self, attributes ):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   584
        self._push(bold=1)
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
   585
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   586
    def end_b( self ):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   587
        self._pop(bold=1)
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
   588
1940
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
   589
    def start_strong( self, attributes ):
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
   590
        self._push(bold=1)
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
   591
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
   592
    def end_strong( self ):
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
   593
        self._pop(bold=1)
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
   594
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   595
    #### italics
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   596
    def start_i( self, attributes ):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   597
        self._push(italic=1)
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
   598
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   599
    def end_i( self ):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   600
        self._pop(italic=1)
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
   601
1940
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
   602
    def start_em( self, attributes ):
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
   603
        self._push(italic=1)
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
   604
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
   605
    def end_em( self ):
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
   606
        self._pop(italic=1)
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
   607
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   608
    #### underline
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   609
    def start_u( self, attributes ):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   610
        self._push(underline=1)
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
   611
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   612
    def end_u( self ):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   613
        self._pop(underline=1)
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
   614
2644
e762ad1c8909 reportlab: add support for strike through
rgbecker
parents: 2594
diff changeset
   615
    #### strike
e762ad1c8909 reportlab: add support for strike through
rgbecker
parents: 2594
diff changeset
   616
    def start_strike( self, attributes ):
e762ad1c8909 reportlab: add support for strike through
rgbecker
parents: 2594
diff changeset
   617
        self._push(strike=1)
e762ad1c8909 reportlab: add support for strike through
rgbecker
parents: 2594
diff changeset
   618
e762ad1c8909 reportlab: add support for strike through
rgbecker
parents: 2594
diff changeset
   619
    def end_strike( self ):
e762ad1c8909 reportlab: add support for strike through
rgbecker
parents: 2594
diff changeset
   620
        self._pop(strike=1)
e762ad1c8909 reportlab: add support for strike through
rgbecker
parents: 2594
diff changeset
   621
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   622
    #### link
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   623
    def start_link(self, attributes):
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   624
        self._push(**self.getAttributes(attributes,_linkAttrMap))
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   625
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   626
    def end_link(self):
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   627
        frag = self._stack[-1]
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   628
        del self._stack[-1]
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   629
        assert frag.link!=None
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   630
2744
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   631
    #### anchor
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   632
    def start_a(self, attributes):
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   633
        A = self.getAttributes(attributes,_anchorAttrMap)
2893
7432e06445ba paraparser.py: improved checking on <a> tag attributes
rgbecker
parents: 2861
diff changeset
   634
        name = A.get('name',None)
7432e06445ba paraparser.py: improved checking on <a> tag attributes
rgbecker
parents: 2861
diff changeset
   635
        if name is not None:
7432e06445ba paraparser.py: improved checking on <a> tag attributes
rgbecker
parents: 2861
diff changeset
   636
            name = name.strip()
7432e06445ba paraparser.py: improved checking on <a> tag attributes
rgbecker
parents: 2861
diff changeset
   637
            if not name:
7432e06445ba paraparser.py: improved checking on <a> tag attributes
rgbecker
parents: 2861
diff changeset
   638
                self._syntax_error('<a name="..."/> anchor variant requires non-blank name')
2744
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   639
            if len(A)>1:
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   640
                self._syntax_error('<a name="..."/> anchor variant only allows name attribute')
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   641
                A = dict(name=A['name'])
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   642
            A['_selfClosingTag'] = 'anchor'
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   643
        else:
2893
7432e06445ba paraparser.py: improved checking on <a> tag attributes
rgbecker
parents: 2861
diff changeset
   644
            href = A.get('href','').strip()
7432e06445ba paraparser.py: improved checking on <a> tag attributes
rgbecker
parents: 2861
diff changeset
   645
            if not href:
7432e06445ba paraparser.py: improved checking on <a> tag attributes
rgbecker
parents: 2861
diff changeset
   646
                self._syntax_error('<a> tag must have non-blank name or href attribute')
7432e06445ba paraparser.py: improved checking on <a> tag attributes
rgbecker
parents: 2861
diff changeset
   647
            A['link'] = href    #convert to our link form
7432e06445ba paraparser.py: improved checking on <a> tag attributes
rgbecker
parents: 2861
diff changeset
   648
            A.pop('href')
2744
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   649
        self._push(**A)
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   650
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   651
    def end_a(self):
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   652
        frag = self._stack[-1]
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   653
        sct = getattr(frag,'_selfClosingTag','')
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   654
        if sct:
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   655
            assert sct=='anchor' and frag.name,'Parser failure in <a/>'
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   656
            defn = frag.cbDefn = ABag()
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   657
            defn.label = defn.kind = 'anchor'
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   658
            defn.name = frag.name
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   659
            del frag.name, frag._selfClosingTag
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   660
            self.handle_data('')
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   661
            self._pop()
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   662
        else:
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   663
            del self._stack[-1]
9472eedb9702 reportlab/platypus: add two way <a> tag
rgbecker
parents: 2742
diff changeset
   664
            assert frag.link!=None
2742
8edd54153201 paraparser: allow <a> as alias for <link>
rgbecker
parents: 2694
diff changeset
   665
2857
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
   666
    def start_img(self,attributes):
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
   667
        A = self.getAttributes(attributes,_imgAttrMap)
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
   668
        if not A.get('src'):
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
   669
            self._syntax_error('<img> needs src attribute')
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
   670
        A['_selfClosingTag'] = 'img'
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
   671
        self._push(**A)
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
   672
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
   673
    def end_img(self):
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
   674
        frag = self._stack[-1]
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
   675
        assert getattr(frag,'_selfClosingTag',''),'Parser failure in <img/>'
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
   676
        defn = frag.cbDefn = ABag()
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
   677
        defn.kind = 'img'
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
   678
        defn.src = getattr(frag,'src',None)
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
   679
        defn.image = ImageReader(defn.src)
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
   680
        size = defn.image.getSize()
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
   681
        defn.width = getattr(frag,'width',size[0])
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
   682
        defn.height = getattr(frag,'height',size[1])
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
   683
        defn.valign = getattr(frag,'valign','bottom')
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
   684
        del frag._selfClosingTag
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
   685
        self.handle_data('')
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
   686
        self._pop()
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
   687
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   688
    #### super script
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   689
    def start_super( self, attributes ):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   690
        self._push(super=1)
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
   691
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   692
    def end_super( self ):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   693
        self._pop(super=1)
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
   694
2376
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
   695
    start_sup = start_super
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
   696
    end_sup = end_super
1736
dafc17db33d2 Attempt to use sup as well as super
rgbecker
parents: 1683
diff changeset
   697
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   698
    #### sub script
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   699
    def start_sub( self, attributes ):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   700
        self._push(sub=1)
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
   701
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   702
    def end_sub( self ):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   703
        self._pop(sub=1)
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
   704
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   705
    #### greek script
2376
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
   706
    #### add symbol encoding
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
   707
    def handle_charref(self, name):
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
   708
        try:
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   709
            if name[0]=='x':
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   710
                n = int(name[1:],16)
1931
784fce255e2d Added in more special entities as suggested by Christoph Zwerschke
rgbecker
parents: 1736
diff changeset
   711
            else:
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   712
                n = int(name)
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   713
        except ValueError:
2376
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
   714
            self.unknown_charref(name)
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
   715
            return
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3656
diff changeset
   716
        self.handle_data(chr(n).encode('utf8'))
134
60e8e0aee073 Fixed syntax_error handling
rgbecker
parents: 133
diff changeset
   717
2376
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
   718
    def handle_entityref(self,name):
3326
ce725978d11c Initial Python3 compatibility fixes
damian
parents: 3188
diff changeset
   719
        if name in greeks:
2376
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
   720
            self.handle_data(greeks[name])
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
   721
        else:
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
   722
            xmllib.XMLParser.handle_entityref(self,name)
134
60e8e0aee073 Fixed syntax_error handling
rgbecker
parents: 133
diff changeset
   723
2376
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
   724
    def syntax_error(self,lineno,message):
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
   725
        self._syntax_error(message)
134
60e8e0aee073 Fixed syntax_error handling
rgbecker
parents: 133
diff changeset
   726
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   727
    def _syntax_error(self,message):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   728
        if message[:10]=="attribute " and message[-17:]==" value not quoted": return
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   729
        self.errors.append(message)
134
60e8e0aee073 Fixed syntax_error handling
rgbecker
parents: 133
diff changeset
   730
2584
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   731
    def start_greek(self, attr):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   732
        self._push(greek=1)
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
   733
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   734
    def end_greek(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   735
        self._pop(greek=1)
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
   736
2584
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   737
    def start_unichar(self, attr):
3326
ce725978d11c Initial Python3 compatibility fixes
damian
parents: 3188
diff changeset
   738
        if 'name' in attr:
ce725978d11c Initial Python3 compatibility fixes
damian
parents: 3188
diff changeset
   739
            if 'code' in attr:
2584
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   740
                self._syntax_error('<unichar/> invalid with both name and code attributes')
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   741
            try:
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   742
                v = unicodedata.lookup(attr['name']).encode('utf8')
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   743
            except KeyError:
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   744
                self._syntax_error('<unichar/> invalid name attribute\n"%s"' % name)
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   745
                v = '\0'
3326
ce725978d11c Initial Python3 compatibility fixes
damian
parents: 3188
diff changeset
   746
        elif 'code' in attr:
2584
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   747
            try:
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3656
diff changeset
   748
                v = chr(int(eval(attr['code']))).encode('utf8')
2584
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   749
            except:
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   750
                self._syntax_error('<unichar/> invalid code attribute %s' % attr['code'])
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   751
                v = '\0'
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   752
        else:
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   753
            v = None
2664
c9faa3a99e93 reportlab/platypus: <br/> tags now working
rgbecker
parents: 2663
diff changeset
   754
            if attr:
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3656
diff changeset
   755
                self._syntax_error('<unichar/> invalid attribute %s' % list(attr.keys())[0])
2584
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   756
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   757
        if v is not None:
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   758
            self.handle_data(v)
2585
ee08fea4505b reportlab: added pound sign
rgbecker
parents: 2584
diff changeset
   759
        self._push(_selfClosingTag='unichar')
2584
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   760
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   761
    def end_unichar(self):
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   762
        self._pop()
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
   763
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   764
    def start_font(self,attr):
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   765
        self._push(**self.getAttributes(attr,_fontAttrMap))
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
   766
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   767
    def end_font(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   768
        self._pop()
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
   769
3552
20ecbcc53c15 paraparser.py add support for <span style=stylename>
rgbecker
parents: 3440
diff changeset
   770
    def start_span(self,attr):
20ecbcc53c15 paraparser.py add support for <span style=stylename>
rgbecker
parents: 3440
diff changeset
   771
        A = self.getAttributes(attr,_spanAttrMap)
20ecbcc53c15 paraparser.py add support for <span style=stylename>
rgbecker
parents: 3440
diff changeset
   772
        if 'style' in A:
20ecbcc53c15 paraparser.py add support for <span style=stylename>
rgbecker
parents: 3440
diff changeset
   773
            style = self.findSpanStyle(A.pop('style'))
20ecbcc53c15 paraparser.py add support for <span style=stylename>
rgbecker
parents: 3440
diff changeset
   774
            D = {}
20ecbcc53c15 paraparser.py add support for <span style=stylename>
rgbecker
parents: 3440
diff changeset
   775
            for k in 'fontName fontSize textColor backColor'.split():
20ecbcc53c15 paraparser.py add support for <span style=stylename>
rgbecker
parents: 3440
diff changeset
   776
                v = getattr(style,k,self)
20ecbcc53c15 paraparser.py add support for <span style=stylename>
rgbecker
parents: 3440
diff changeset
   777
                if v is self: continue
20ecbcc53c15 paraparser.py add support for <span style=stylename>
rgbecker
parents: 3440
diff changeset
   778
                D[k] = v
20ecbcc53c15 paraparser.py add support for <span style=stylename>
rgbecker
parents: 3440
diff changeset
   779
            D.update(A)
20ecbcc53c15 paraparser.py add support for <span style=stylename>
rgbecker
parents: 3440
diff changeset
   780
            A = D
20ecbcc53c15 paraparser.py add support for <span style=stylename>
rgbecker
parents: 3440
diff changeset
   781
        self._push(**A)
20ecbcc53c15 paraparser.py add support for <span style=stylename>
rgbecker
parents: 3440
diff changeset
   782
20ecbcc53c15 paraparser.py add support for <span style=stylename>
rgbecker
parents: 3440
diff changeset
   783
    end_span = end_font
20ecbcc53c15 paraparser.py add support for <span style=stylename>
rgbecker
parents: 3440
diff changeset
   784
2663
927cc273c5a5 <br/> work in progress
andy
parents: 2646
diff changeset
   785
    def start_br(self, attr):
927cc273c5a5 <br/> work in progress
andy
parents: 2646
diff changeset
   786
        #just do the trick to make sure there is no content
2664
c9faa3a99e93 reportlab/platypus: <br/> tags now working
rgbecker
parents: 2663
diff changeset
   787
        self._push(_selfClosingTag='br',lineBreak=True,text='')
2663
927cc273c5a5 <br/> work in progress
andy
parents: 2646
diff changeset
   788
927cc273c5a5 <br/> work in progress
andy
parents: 2646
diff changeset
   789
    def end_br(self):
2664
c9faa3a99e93 reportlab/platypus: <br/> tags now working
rgbecker
parents: 2663
diff changeset
   790
        frag = self._stack[-1]
c9faa3a99e93 reportlab/platypus: <br/> tags now working
rgbecker
parents: 2663
diff changeset
   791
        assert frag._selfClosingTag=='br' and frag.lineBreak,'Parser failure in <br/>'
c9faa3a99e93 reportlab/platypus: <br/> tags now working
rgbecker
parents: 2663
diff changeset
   792
        del frag._selfClosingTag
c9faa3a99e93 reportlab/platypus: <br/> tags now working
rgbecker
parents: 2663
diff changeset
   793
        self.handle_data('')
c9faa3a99e93 reportlab/platypus: <br/> tags now working
rgbecker
parents: 2663
diff changeset
   794
        self._pop()
2663
927cc273c5a5 <br/> work in progress
andy
parents: 2646
diff changeset
   795
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   796
    def _initial_frag(self,attr,attrMap,bullet=0):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   797
        style = self._style
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   798
        if attr!={}:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   799
            style = copy.deepcopy(style)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   800
            _applyAttributes(style,self.getAttributes(attr,attrMap))
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   801
            self._style = style
119
b4dc589c8364 <para> tag added in layout.py paraparser.py
rgbecker
parents: 115
diff changeset
   802
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   803
        # initialize semantic values
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   804
        frag = ParaFrag()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   805
        frag.sub = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   806
        frag.super = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   807
        frag.rise = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   808
        frag.underline = 0
2644
e762ad1c8909 reportlab: add support for strike through
rgbecker
parents: 2594
diff changeset
   809
        frag.strike = 0
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   810
        frag.greek = 0
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   811
        frag.link = None
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   812
        if bullet:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   813
            frag.fontName, frag.bold, frag.italic = ps2tt(style.bulletFontName)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   814
            frag.fontSize = style.bulletFontSize
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   815
            frag.textColor = hasattr(style,'bulletColor') and style.bulletColor or style.textColor
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   816
        else:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   817
            frag.fontName, frag.bold, frag.italic = ps2tt(style.fontName)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   818
            frag.fontSize = style.fontSize
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   819
            frag.textColor = style.textColor
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   820
        return frag
250
a1bcf9c6c21e <bullet> xml tag added
rgbecker
parents: 248
diff changeset
   821
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   822
    def start_para(self,attr):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   823
        self._stack = [self._initial_frag(attr,_paraAttrMap)]
119
b4dc589c8364 <para> tag added in layout.py paraparser.py
rgbecker
parents: 115
diff changeset
   824
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   825
    def end_para(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   826
        self._pop()
119
b4dc589c8364 <para> tag added in layout.py paraparser.py
rgbecker
parents: 115
diff changeset
   827
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   828
    def start_bullet(self,attr):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   829
        if hasattr(self,'bFragList'):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   830
            self._syntax_error('only one <bullet> tag allowed')
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   831
        self.bFragList = []
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   832
        frag = self._initial_frag(attr,_bulletAttrMap,1)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   833
        frag.isBullet = 1
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   834
        self._stack.append(frag)
250
a1bcf9c6c21e <bullet> xml tag added
rgbecker
parents: 248
diff changeset
   835
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   836
    def end_bullet(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   837
        self._pop()
250
a1bcf9c6c21e <bullet> xml tag added
rgbecker
parents: 248
diff changeset
   838
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   839
    #---------------------------------------------------------------
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   840
    def start_seqdefault(self, attr):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   841
        try:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   842
            default = attr['id']
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   843
        except KeyError:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   844
            default = None
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   845
        self._seq.setDefaultCounter(default)
266
081154da1a78 Added Sequencer and associated XML tags
andy_robinson
parents: 253
diff changeset
   846
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   847
    def end_seqdefault(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   848
        pass
1683
7fa753e4420a Removed all trailing whitespace
andy_robinson
parents: 1677
diff changeset
   849
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   850
    def start_seqreset(self, attr):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   851
        try:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   852
            id = attr['id']
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   853
        except KeyError:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   854
            id = None
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   855
        try:
2368
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   856
            base = int(attr['base'])
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   857
        except:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   858
            base=0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   859
        self._seq.reset(id, base)
266
081154da1a78 Added Sequencer and associated XML tags
andy_robinson
parents: 253
diff changeset
   860
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   861
    def end_seqreset(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   862
        pass
744
2abd99baf95b Accepts seqdefault/seqDefault and seqreset/seqReset
andy_robinson
parents: 677
diff changeset
   863
2368
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   864
    def start_seqchain(self, attr):
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   865
        try:
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   866
            order = attr['order']
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   867
        except KeyError:
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   868
            order = ''
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   869
        order = order.split()
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   870
        seq = self._seq
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   871
        for p,c in zip(order[:-1],order[1:]):
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   872
            seq.chain(p, c)
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   873
    end_seqchain = end_seqreset
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   874
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   875
    def start_seqformat(self, attr):
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   876
        try:
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   877
            id = attr['id']
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   878
        except KeyError:
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   879
            id = None
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   880
        try:
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   881
            value = attr['value']
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   882
        except KeyError:
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   883
            value = '1'
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   884
        self._seq.setFormat(id,value)
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   885
    end_seqformat = end_seqreset
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   886
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   887
    # AR hacking in aliases to allow the proper casing for RML.
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   888
    # the above ones should be deprecated over time. 2001-03-22
2368
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   889
    start_seqDefault = start_seqdefault
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   890
    end_seqDefault = end_seqdefault
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   891
    start_seqReset = start_seqreset
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   892
    end_seqReset = end_seqreset
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   893
    start_seqChain = start_seqchain
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   894
    end_seqChain = end_seqchain
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   895
    start_seqFormat = start_seqformat
791a362e9cae added seqchain/format tags
rgbecker
parents: 2341
diff changeset
   896
    end_seqFormat = end_seqformat
1683
7fa753e4420a Removed all trailing whitespace
andy_robinson
parents: 1677
diff changeset
   897
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   898
    def start_seq(self, attr):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   899
        #if it has a template, use that; otherwise try for id;
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   900
        #otherwise take default sequence
3326
ce725978d11c Initial Python3 compatibility fixes
damian
parents: 3188
diff changeset
   901
        if 'template' in attr:
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   902
            templ = attr['template']
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   903
            self.handle_data(templ % self._seq)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   904
            return
3326
ce725978d11c Initial Python3 compatibility fixes
damian
parents: 3188
diff changeset
   905
        elif 'id' in attr:
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   906
            id = attr['id']
1683
7fa753e4420a Removed all trailing whitespace
andy_robinson
parents: 1677
diff changeset
   907
        else:
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   908
            id = None
2694
dd0ea6474ea0 fixes to crashing PTO trailer when empty, and numbering
andy
parents: 2693
diff changeset
   909
        increment = attr.get('inc', None)
dd0ea6474ea0 fixes to crashing PTO trailer when empty, and numbering
andy
parents: 2693
diff changeset
   910
        if not increment:
dd0ea6474ea0 fixes to crashing PTO trailer when empty, and numbering
andy
parents: 2693
diff changeset
   911
            output = self._seq.nextf(id)
dd0ea6474ea0 fixes to crashing PTO trailer when empty, and numbering
andy
parents: 2693
diff changeset
   912
        else:
dd0ea6474ea0 fixes to crashing PTO trailer when empty, and numbering
andy
parents: 2693
diff changeset
   913
            #accepts "no" for do not increment, or an integer.
dd0ea6474ea0 fixes to crashing PTO trailer when empty, and numbering
andy
parents: 2693
diff changeset
   914
            #thus, 0 and 1 increment by the right amounts.
dd0ea6474ea0 fixes to crashing PTO trailer when empty, and numbering
andy
parents: 2693
diff changeset
   915
            if increment.lower() == 'no':
dd0ea6474ea0 fixes to crashing PTO trailer when empty, and numbering
andy
parents: 2693
diff changeset
   916
                output = self._seq.thisf(id)
dd0ea6474ea0 fixes to crashing PTO trailer when empty, and numbering
andy
parents: 2693
diff changeset
   917
            else:
dd0ea6474ea0 fixes to crashing PTO trailer when empty, and numbering
andy
parents: 2693
diff changeset
   918
                incr = int(increment)
dd0ea6474ea0 fixes to crashing PTO trailer when empty, and numbering
andy
parents: 2693
diff changeset
   919
                output = self._seq.thisf(id)
dd0ea6474ea0 fixes to crashing PTO trailer when empty, and numbering
andy
parents: 2693
diff changeset
   920
                self._seq.reset(id, self._seq._this() + incr)
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   921
        self.handle_data(output)
1683
7fa753e4420a Removed all trailing whitespace
andy_robinson
parents: 1677
diff changeset
   922
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   923
    def end_seq(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   924
        pass
266
081154da1a78 Added Sequencer and associated XML tags
andy_robinson
parents: 253
diff changeset
   925
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   926
    def start_onDraw(self,attr):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   927
        defn = ABag()
3326
ce725978d11c Initial Python3 compatibility fixes
damian
parents: 3188
diff changeset
   928
        if 'name' in attr: defn.name = attr['name']
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   929
        else: self._syntax_error('<onDraw> needs at least a name attribute')
506
68bd275f16e2 Added onDraw tag to paragraphs
rgbecker
parents: 494
diff changeset
   930
3326
ce725978d11c Initial Python3 compatibility fixes
damian
parents: 3188
diff changeset
   931
        if 'label' in attr: defn.label = attr['label']
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   932
        defn.kind='onDraw'
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   933
        self._push(cbDefn=defn)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   934
        self.handle_data('')
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   935
        self._pop()
3111
86a3158c50bd reportlab: improved support for onDraw and SimpleIndex
rgbecker
parents: 3032
diff changeset
   936
    end_onDraw=end_seq
86a3158c50bd reportlab: improved support for onDraw and SimpleIndex
rgbecker
parents: 3032
diff changeset
   937
3165
cbda9e7d0ee3 reportlab: new index support
rgbecker
parents: 3137
diff changeset
   938
    def start_index(self,attr):
cbda9e7d0ee3 reportlab: new index support
rgbecker
parents: 3137
diff changeset
   939
        attr=self.getAttributes(attr,_indexAttrMap)
cbda9e7d0ee3 reportlab: new index support
rgbecker
parents: 3137
diff changeset
   940
        defn = ABag()
3326
ce725978d11c Initial Python3 compatibility fixes
damian
parents: 3188
diff changeset
   941
        if 'item' in attr:
3187
2d5a6655556e tableofcontents/paraparser: allow for format and offset parameters
rgbecker
parents: 3165
diff changeset
   942
            label = attr['item']
3165
cbda9e7d0ee3 reportlab: new index support
rgbecker
parents: 3137
diff changeset
   943
        else:
cbda9e7d0ee3 reportlab: new index support
rgbecker
parents: 3137
diff changeset
   944
            self._syntax_error('<index> needs at least an item attribute')
3326
ce725978d11c Initial Python3 compatibility fixes
damian
parents: 3188
diff changeset
   945
        if 'name' in attr:
3165
cbda9e7d0ee3 reportlab: new index support
rgbecker
parents: 3137
diff changeset
   946
            name = attr['name']
cbda9e7d0ee3 reportlab: new index support
rgbecker
parents: 3137
diff changeset
   947
        else:
cbda9e7d0ee3 reportlab: new index support
rgbecker
parents: 3137
diff changeset
   948
            name = DEFAULT_INDEX_NAME
3187
2d5a6655556e tableofcontents/paraparser: allow for format and offset parameters
rgbecker
parents: 3165
diff changeset
   949
        format = attr.get('format',None)
2d5a6655556e tableofcontents/paraparser: allow for format and offset parameters
rgbecker
parents: 3165
diff changeset
   950
        if format is not None and format not in ('123','I','i','ABC','abc'):
2d5a6655556e tableofcontents/paraparser: allow for format and offset parameters
rgbecker
parents: 3165
diff changeset
   951
            raise ValueError('index tag format is %r not valid 123 I i ABC or abc' % offset)
2d5a6655556e tableofcontents/paraparser: allow for format and offset parameters
rgbecker
parents: 3165
diff changeset
   952
        offset = attr.get('offset',None)
2d5a6655556e tableofcontents/paraparser: allow for format and offset parameters
rgbecker
parents: 3165
diff changeset
   953
        if offset is not None:
2d5a6655556e tableofcontents/paraparser: allow for format and offset parameters
rgbecker
parents: 3165
diff changeset
   954
            try:
2d5a6655556e tableofcontents/paraparser: allow for format and offset parameters
rgbecker
parents: 3165
diff changeset
   955
                offset = int(offset)
2d5a6655556e tableofcontents/paraparser: allow for format and offset parameters
rgbecker
parents: 3165
diff changeset
   956
            except:
2d5a6655556e tableofcontents/paraparser: allow for format and offset parameters
rgbecker
parents: 3165
diff changeset
   957
                raise ValueError('index tag offset is %r not an int' % offset)
3188
be6793854075 paraparser.py: fix broken code and wrong module name
rgbecker
parents: 3187
diff changeset
   958
        defn.label = base64.encodestring(pickle.dumps((label,format,offset))).strip()
3165
cbda9e7d0ee3 reportlab: new index support
rgbecker
parents: 3137
diff changeset
   959
        defn.name = name
cbda9e7d0ee3 reportlab: new index support
rgbecker
parents: 3137
diff changeset
   960
        defn.kind='index'
cbda9e7d0ee3 reportlab: new index support
rgbecker
parents: 3137
diff changeset
   961
        self._push(cbDefn=defn)
cbda9e7d0ee3 reportlab: new index support
rgbecker
parents: 3137
diff changeset
   962
        self.handle_data('')
cbda9e7d0ee3 reportlab: new index support
rgbecker
parents: 3137
diff changeset
   963
        self._pop()
cbda9e7d0ee3 reportlab: new index support
rgbecker
parents: 3137
diff changeset
   964
    end_index=end_seq
2663
927cc273c5a5 <br/> work in progress
andy
parents: 2646
diff changeset
   965
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   966
    #---------------------------------------------------------------
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   967
    def _push(self,**attr):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   968
        frag = copy.copy(self._stack[-1])
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   969
        _applyAttributes(frag,attr)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   970
        self._stack.append(frag)
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
   971
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   972
    def _pop(self,**kw):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   973
        frag = self._stack[-1]
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   974
        del self._stack[-1]
3723
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   975
        for k, v in kw.items():
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   976
            assert getattr(frag,k)==v
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   977
        return frag
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
   978
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   979
    def getAttributes(self,attr,attrMap):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   980
        A = {}
3723
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   981
        for k, v in attr.items():
1940
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
   982
            if not self.caseSensitive:
baa0abc136c4 Henning von Bargen's caseSensitive flag
rgbecker
parents: 1932
diff changeset
   983
                k = string.lower(k)
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3656
diff changeset
   984
            if k in list(attrMap.keys()):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   985
                j = attrMap[k]
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   986
                func = j[1]
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   987
                try:
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
   988
                    A[j[0]] = (func is None) and v or func(v)
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   989
                except:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   990
                    self._syntax_error('%s: invalid value %s'%(k,v))
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   991
            else:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   992
                self._syntax_error('invalid attribute name %s'%k)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   993
        return A
119
b4dc589c8364 <para> tag added in layout.py paraparser.py
rgbecker
parents: 115
diff changeset
   994
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   995
    #----------------------------------------------------------------
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
   996
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
   997
    def __init__(self,verbose=0):
1944
a50f8e3f93f8 laissez faire case
rgbecker
parents: 1940
diff changeset
   998
        self.caseSensitive = 0
2376
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
   999
        xmllib.XMLParser.__init__(self,verbose=verbose)
266
081154da1a78 Added Sequencer and associated XML tags
andy_robinson
parents: 253
diff changeset
  1000
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1001
    def _iReset(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1002
        self.fragList = []
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1003
        if hasattr(self, 'bFragList'): delattr(self,'bFragList')
250
a1bcf9c6c21e <bullet> xml tag added
rgbecker
parents: 248
diff changeset
  1004
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1005
    def _reset(self, style):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1006
        '''reset the parser'''
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1007
        xmllib.XMLParser.reset(self)
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
  1008
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1009
        # initialize list of string segments to empty
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1010
        self.errors = []
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1011
        self._style = style
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1012
        self._iReset()
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
  1013
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1014
    #----------------------------------------------------------------
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1015
    def handle_data(self,data):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1016
        "Creates an intermediate representation of string segments."
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
  1017
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1018
        frag = copy.copy(self._stack[-1])
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1019
        if hasattr(frag,'cbDefn'):
2857
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
  1020
            kind = frag.cbDefn.kind
487dc2450eec reprotlab: inline images horizontal positioning OK
rgbecker
parents: 2836
diff changeset
  1021
            if data: self._syntax_error('Only empty <%s> tag allowed' % kind)
2584
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
  1022
        elif hasattr(frag,'_selfClosingTag'):
2663
927cc273c5a5 <br/> work in progress
andy
parents: 2646
diff changeset
  1023
            if data!='': self._syntax_error('No content allowed in %s tag' % frag._selfClosingTag)
2584
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
  1024
            return
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1025
        else:
1736
dafc17db33d2 Attempt to use sup as well as super
rgbecker
parents: 1683
diff changeset
  1026
            # if sub and super are both on they will cancel each other out
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1027
            if frag.sub == 1 and frag.super == 1:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1028
                frag.sub = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1029
                frag.super = 0
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
  1030
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1031
            if frag.sub:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1032
                frag.rise = -frag.fontSize*subFraction
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1033
                frag.fontSize = max(frag.fontSize-sizeDelta,3)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1034
            elif frag.super:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1035
                frag.rise = frag.fontSize*superFraction
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1036
                frag.fontSize = max(frag.fontSize-sizeDelta,3)
112
1d4892961fdb Added rise attribute
rgbecker
parents: 102
diff changeset
  1037
2584
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
  1038
            if frag.greek:
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
  1039
                frag.fontName = 'symbol'
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
  1040
                data = _greekConvert(data)
514
3784fe357a72 Slight optimisation in handle_data for cbdefn frags
rgbecker
parents: 508
diff changeset
  1041
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1042
        # bold, italic, and underline
2861
2096955de8cf platypus: autoLeading vertical pos improvement
rgbecker
parents: 2860
diff changeset
  1043
        frag.fontName = tt2ps(frag.fontName,frag.bold,frag.italic)
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
  1044
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1045
        #save our data
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1046
        frag.text = data
514
3784fe357a72 Slight optimisation in handle_data for cbdefn frags
rgbecker
parents: 508
diff changeset
  1047
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1048
        if hasattr(frag,'isBullet'):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1049
            delattr(frag,'isBullet')
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1050
            self.bFragList.append(frag)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1051
        else:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1052
            self.fragList.append(frag)
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
  1053
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1054
    def handle_cdata(self,data):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1055
        self.handle_data(data)
211
52541f1643b6 CDATA handler added
rgbecker
parents: 209
diff changeset
  1056
2376
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
  1057
    def _setup_for_parse(self,style):
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
  1058
        self._seq = reportlab.lib.sequencer.getSequencer()
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
  1059
        self._reset(style)  # reinitialise the parser
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
  1060
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1061
    def parse(self, text, style):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1062
        """Given a formatted string will return a list of
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1063
        ParaFrag objects with their calculated widths.
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1064
        If errors occur None will be returned and the
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1065
        self.errors holds a list of the error messages.
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1066
        """
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
  1067
        # AR 20040612 - when we feed Unicode strings in, sgmlop
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
  1068
        # tries to coerce to ASCII.  Must intercept, coerce to
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
  1069
        # any 8-bit encoding which defines most of 256 points,
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
  1070
        # and revert at end.  Yuk.  Preliminary step prior to
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
  1071
        # removal of parser altogether.
2646
d177c247184a platypus: eliminate StringType usages and cp1252 usage
rgbecker
parents: 2644
diff changeset
  1072
        enc = self._enc = 'utf8' #our legacy default
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
  1073
        self._UNI = type(text) is UnicodeType
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
  1074
        if self._UNI:
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
  1075
            text = text.encode(enc)
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
  1076
2376
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
  1077
        self._setup_for_parse(style)
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1078
        # the xmlparser requires that all text be surrounded by xml
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1079
        # tags, therefore we must throw some unused flags around the
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1080
        # given string
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1081
        if not(len(text)>=6 and text[0]=='<' and _re_para.match(text)):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1082
            text = "<para>"+text+"</para>"
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1083
        self.feed(text)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1084
        self.close()    # force parsing to complete
2376
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
  1085
        return self._complete_parse()
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
  1086
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
  1087
    def _complete_parse(self):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1088
        del self._seq
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1089
        style = self._style
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1090
        del self._style
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1091
        if len(self.errors)==0:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1092
            fragList = self.fragList
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1093
            bFragList = hasattr(self,'bFragList') and self.bFragList or None
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1094
            self._iReset()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1095
        else:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1096
            fragList = bFragList = None
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
  1097
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
  1098
        if self._UNI:
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
  1099
            #reconvert to unicode
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
  1100
            if fragList:
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
  1101
                for frag in fragList:
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3656
diff changeset
  1102
                    frag.text = str(frag.text, self._enc)
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
  1103
            if bFragList:
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2446
diff changeset
  1104
                for frag in bFragList:
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3656
diff changeset
  1105
                    frag.text = str(frag.text, self._enc)
2664
c9faa3a99e93 reportlab/platypus: <br/> tags now working
rgbecker
parents: 2663
diff changeset
  1106
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1107
        return style, fragList, bFragList
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
  1108
2376
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
  1109
    def _tt_parse(self,tt):
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
  1110
        tag = tt[0]
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
  1111
        try:
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
  1112
            start = getattr(self,'start_'+tag)
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
  1113
            end = getattr(self,'end_'+tag)
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
  1114
        except AttributeError:
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
  1115
            raise ValueError('Invalid tag "%s"' % tag)
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
  1116
        start(tt[1] or {})
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
  1117
        C = tt[2]
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
  1118
        if C:
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
  1119
            M = self._tt_handlers
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
  1120
            for c in C:
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
  1121
                M[type(c) is TupleType](c)
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
  1122
        end()
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
  1123
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
  1124
    def tt_parse(self,tt,style):
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
  1125
        '''parse from tupletree form'''
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
  1126
        self._setup_for_parse(style)
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
  1127
        self._tt_handlers = self.handle_data,self._tt_parse
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
  1128
        self._tt_parse(tt)
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
  1129
        return self._complete_parse()
7e70411a7236 flowables.py: minor change to PTOContainer
rgbecker
parents: 2369
diff changeset
  1130
3552
20ecbcc53c15 paraparser.py add support for <span style=stylename>
rgbecker
parents: 3440
diff changeset
  1131
    def findSpanStyle(self,style):
20ecbcc53c15 paraparser.py add support for <span style=stylename>
rgbecker
parents: 3440
diff changeset
  1132
        raise ValueError('findSpanStyle not implemented in this parser')
20ecbcc53c15 paraparser.py add support for <span style=stylename>
rgbecker
parents: 3440
diff changeset
  1133
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
  1134
if __name__=='__main__':
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1135
    from reportlab.platypus import cleanBlockQuotedText
3368
afa025c34493 reportlab: new base font mechanism more fully applied
rgbecker
parents: 3326
diff changeset
  1136
    from reportlab.lib.styles import _baseFontName
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1137
    _parser=ParaParser()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1138
    def check_text(text,p=_parser):
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3656
diff changeset
  1139
        print('##########')
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1140
        text = cleanBlockQuotedText(text)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1141
        l,rv,bv = p.parse(text,style)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1142
        if rv is None:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1143
            for l in _parser.errors:
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3656
diff changeset
  1144
                print(l)
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1145
        else:
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3656
diff changeset
  1146
            print('ParaStyle', l.fontName,l.fontSize,l.textColor)
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1147
            for l in rv:
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3656
diff changeset
  1148
                print(l.fontName,l.fontSize,l.textColor,l.bold, l.rise, '|%s|'%l.text[:25], end=' ')
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1149
                if hasattr(l,'cbDefn'):
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3656
diff changeset
  1150
                    print('cbDefn',getattr(l.cbDefn,'name',''),getattr(l.cbDefn,'label',''),l.cbDefn.kind)
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3656
diff changeset
  1151
                else: print()
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
  1152
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1153
    style=ParaFrag()
3368
afa025c34493 reportlab: new base font mechanism more fully applied
rgbecker
parents: 3326
diff changeset
  1154
    style.fontName=_baseFontName
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1155
    style.fontSize = 12
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1156
    style.textColor = black
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1157
    style.bulletFontName = black
3368
afa025c34493 reportlab: new base font mechanism more fully applied
rgbecker
parents: 3326
diff changeset
  1158
    style.bulletFontName=_baseFontName
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1159
    style.bulletFontSize=12
96
2a9cca4c5cf0 Beginnings of a paragraph parser
rgbecker
parents:
diff changeset
  1160
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1161
    text='''
2584
0fed2bd8ef90 reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents: 2575
diff changeset
  1162
    <b><i><greek>a</greek>D</i></b>&beta;<unichr value="0x394"/>
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1163
    <font name="helvetica" size="15" color=green>
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1164
    Tell me, O muse, of that ingenious hero who travelled far and wide
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1165
    after</font> he had sacked the famous town of Troy. Many cities did he visit,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1166
    and many were the nations with whose manners and customs he was acquainted;
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1167
    moreover he suffered much by sea while trying to save his own life
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1168
    and bring his men safely home; but do what he might he could not save
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1169
    his men, for they perished through their own sheer folly in eating
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1170
    the cattle of the Sun-god Hyperion; so the god prevented them from
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1171
    ever reaching home. Tell me, too, about all these things, O daughter
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1172
    of Jove, from whatsoever source you<super>1</super> may know them.
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1173
    '''
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1174
    check_text(text)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1175
    check_text('<para> </para>')
3368
afa025c34493 reportlab: new base font mechanism more fully applied
rgbecker
parents: 3326
diff changeset
  1176
    check_text('<para font="%s" size=24 leading=28.8 spaceAfter=72>ReportLab -- Reporting for the Internet Age</para>'%_baseFontName)
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1177
    check_text('''
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1178
    <font color=red>&tau;</font>Tell me, O muse, of that ingenious hero who travelled far and wide
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1179
    after he had sacked the famous town of Troy. Many cities did he visit,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1180
    and many were the nations with whose manners and customs he was acquainted;
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1181
    moreover he suffered much by sea while trying to save his own life
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1182
    and bring his men safely home; but do what he might he could not save
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1183
    his men, for they perished through their own sheer folly in eating
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1184
    the cattle of the Sun-god Hyperion; so the god prevented them from
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1185
    ever reaching home. Tell me, too, about all these things, O daughter
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1186
    of Jove, from whatsoever source you may know them.''')
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1187
    check_text('''
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1188
    Telemachus took this speech as of good omen and rose at once, for
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1189
    he was bursting with what he had to say. He stood in the middle of
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1190
    the assembly and the good herald Pisenor brought him his staff. Then,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1191
    turning to Aegyptius, "Sir," said he, "it is I, as you will shortly
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1192
    learn, who have convened you, for it is I who am the most aggrieved.
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1193
    I have not got wind of any host approaching about which I would warn
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1194
    you, nor is there any matter of public moment on which I would speak.
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1195
    My grieveance is purely personal, and turns on two great misfortunes
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1196
    which have fallen upon my house. The first of these is the loss of
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1197
    my excellent father, who was chief among all you here present, and
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1198
    was like a father to every one of you; the second is much more serious,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1160
diff changeset
  1199
    and ere long will be the utter ruin of my estate. The sons of all