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