author | robin |
Mon, 06 Jun 2016 14:27:51 +0100 | |
changeset 4277 | 838129322a55 |
parent 4255 | 89ea1d46b4a0 |
child 4315 | 7c65c6e52b13 |
permissions | -rw-r--r-- |
4252 | 1 |
#Copyright ReportLab Europe Ltd. 2000-2016 |
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 |
4252 | 4 |
__version__='3.3.0' |
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 |
3954
44dbe56eb858
first attempt at HTMLParser-based paraparser
Andy Robinson <andy@reportlab.com>
parents:
3937
diff
changeset
|
12 |
from pprint import pprint as pp |
2693 | 13 |
import unicodedata |
279 | 14 |
import reportlab.lib.sequencer |
3954
44dbe56eb858
first attempt at HTMLParser-based paraparser
Andy Robinson <andy@reportlab.com>
parents:
3937
diff
changeset
|
15 |
|
518 | 16 |
from reportlab.lib.abag import ABag |
4220
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
17 |
from reportlab.lib.utils import ImageReader, isPy3, annotateException, encode_label, asUnicode, asBytes, uniChr, isStr |
248 | 18 |
from reportlab.lib.colors import toColor, white, black, red, Color |
96 | 19 |
from reportlab.lib.fonts import tt2ps, ps2tt |
119 | 20 |
from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY |
1940 | 21 |
from reportlab.lib.units import inch,mm,cm,pica |
3955 | 22 |
if isPy3: |
23 |
from html.parser import HTMLParser |
|
24 |
from html.entities import name2codepoint |
|
25 |
else: |
|
26 |
from HTMLParser import HTMLParser |
|
27 |
from htmlentitydefs import name2codepoint |
|
28 |
||
2410 | 29 |
_re_para = re.compile(r'^\s*<\s*para(?:\s+|>|/>)') |
96 | 30 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
31 |
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
|
32 |
subFraction = 0.5 # fraction of font size that a sub script should be lowered |
4249
8fc7d11bdee0
add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents:
4220
diff
changeset
|
33 |
supFraction = 0.5 # fraction of font size that a super script should be raised |
96 | 34 |
|
3165 | 35 |
DEFAULT_INDEX_NAME='_indexAdd' |
36 |
||
3434
3c14212cc997
platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents:
3368
diff
changeset
|
37 |
def _convnum(s, unit=1, allowRelative=True): |
3c14212cc997
platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents:
3368
diff
changeset
|
38 |
if s[0] in ('+','-') and allowRelative: |
2857
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
39 |
try: |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
40 |
return ('relative',int(s)*unit) |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
41 |
except ValueError: |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
42 |
return ('relative',float(s)*unit) |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
43 |
else: |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
44 |
try: |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
45 |
return int(s)*unit |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
46 |
except ValueError: |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
47 |
return float(s)*unit |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
48 |
|
3434
3c14212cc997
platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents:
3368
diff
changeset
|
49 |
def _num(s, unit=1, allowRelative=True): |
1940 | 50 |
"""Convert a string like '10cm' to an int or float (in points). |
51 |
The default unit is point, but optionally you can use other |
|
52 |
default units like mm. |
|
53 |
""" |
|
3434
3c14212cc997
platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents:
3368
diff
changeset
|
54 |
if s.endswith('cm'): |
1940 | 55 |
unit=cm |
56 |
s = s[:-2] |
|
3434
3c14212cc997
platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents:
3368
diff
changeset
|
57 |
if s.endswith('in'): |
1940 | 58 |
unit=inch |
59 |
s = s[:-2] |
|
3434
3c14212cc997
platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents:
3368
diff
changeset
|
60 |
if s.endswith('pt'): |
1940 | 61 |
unit=1 |
62 |
s = s[:-2] |
|
3434
3c14212cc997
platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents:
3368
diff
changeset
|
63 |
if s.endswith('i'): |
1940 | 64 |
unit=inch |
65 |
s = s[:-1] |
|
3434
3c14212cc997
platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents:
3368
diff
changeset
|
66 |
if s.endswith('mm'): |
1940 | 67 |
unit=mm |
68 |
s = s[:-2] |
|
3434
3c14212cc997
platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents:
3368
diff
changeset
|
69 |
if s.endswith('pica'): |
1940 | 70 |
unit=pica |
71 |
s = s[:-4] |
|
3434
3c14212cc997
platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents:
3368
diff
changeset
|
72 |
return _convnum(s,unit,allowRelative) |
3c14212cc997
platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents:
3368
diff
changeset
|
73 |
|
4220
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
74 |
def _int(s): |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
75 |
try: |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
76 |
return int(s) |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
77 |
except: |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
78 |
raise ValueError('cannot convert %r to int' % s) |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
79 |
|
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
80 |
def _bool(s): |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
81 |
s = s.lower() |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
82 |
if s in ('true','1','yes'): |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
83 |
return True |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
84 |
if s in ('false','0','no'): |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
85 |
return False |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
86 |
raise ValueError('cannot convert %r to bool value' % s) |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
87 |
|
3434
3c14212cc997
platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents:
3368
diff
changeset
|
88 |
def _numpct(s,unit=1,allowRelative=False): |
3c14212cc997
platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents:
3368
diff
changeset
|
89 |
if s.endswith('%'): |
3c14212cc997
platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents:
3368
diff
changeset
|
90 |
return _PCT(_convnum(s[:-1],allowRelative=allowRelative)) |
3c14212cc997
platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents:
3368
diff
changeset
|
91 |
else: |
3c14212cc997
platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents:
3368
diff
changeset
|
92 |
return _num(s,unit,allowRelative) |
2857
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
93 |
|
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
94 |
class _PCT: |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
95 |
def __init__(self,v): |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
96 |
self._value = v*0.01 |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
97 |
|
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
98 |
def normalizedValue(self,normalizer): |
3434
3c14212cc997
platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents:
3368
diff
changeset
|
99 |
normalizer = normalizer or getattr(self,'_normalizer') |
2857
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
100 |
return normalizer*self._value |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
101 |
|
4255
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
102 |
def fontSizeNormalize(frag,attr,default): |
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
103 |
if not hasattr(frag,attr): return default |
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
104 |
v = _numpct(getattr(frag,attr),allowRelative=True) |
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
105 |
return (v[1]+frag.fontSize) if isinstance(v,tuple) else v.normalizedValue(frag.fontSize) if isinstance(v,_PCT) else v |
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
106 |
|
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
107 |
class _CheckSup: |
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
108 |
'''class for syntax checking <sup> attributes |
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
109 |
if the check succeeds then we always return the string for later evaluation |
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
110 |
''' |
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
111 |
def __init__(self,kind): |
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
112 |
self.kind = kind |
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
113 |
self.fontSize = 10 |
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
114 |
|
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
115 |
def __call__(self,s): |
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
116 |
setattr(self,self.kind,s) |
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
117 |
try: |
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
118 |
fontSizeNormalize(self,self.kind,None) |
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
119 |
return s |
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
120 |
except: |
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
121 |
raise ValueError('<sup> invalid value %r for attribute %s' % (s,self.kind)) |
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
122 |
|
2857
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
123 |
def _valignpc(s): |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
124 |
s = s.lower() |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
125 |
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
|
126 |
return s |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
127 |
if s.endswith('%'): |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
128 |
n = _convnum(s[:-1]) |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
129 |
if isinstance(n,tuple): |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
130 |
n = n[1] |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
131 |
return _PCT(n) |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
132 |
n = _num(s) |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
133 |
if isinstance(n,tuple): |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
134 |
n = n[1] |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
135 |
return n |
119 | 136 |
|
2836 | 137 |
def _autoLeading(x): |
138 |
x = x.lower() |
|
139 |
if x in ('','min','max','off'): |
|
140 |
return x |
|
141 |
raise ValueError('Invalid autoLeading=%r' % x ) |
|
142 |
||
119 | 143 |
def _align(s): |
3731 | 144 |
s = s.lower() |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
145 |
if s=='left': return TA_LEFT |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
146 |
elif s=='right': return TA_RIGHT |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
147 |
elif s=='justify': return TA_JUSTIFY |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
148 |
elif s in ('centre','center'): return TA_CENTER |
4136
16f067cf3dae
added rl_settings.decimalSymbol & support for simple bullet anchoring, version-->3.1.35
robin
parents:
4130
diff
changeset
|
149 |
else: raise ValueError('illegal alignment %r' % s) |
16f067cf3dae
added rl_settings.decimalSymbol & support for simple bullet anchoring, version-->3.1.35
robin
parents:
4130
diff
changeset
|
150 |
|
16f067cf3dae
added rl_settings.decimalSymbol & support for simple bullet anchoring, version-->3.1.35
robin
parents:
4130
diff
changeset
|
151 |
def _bAnchor(s): |
16f067cf3dae
added rl_settings.decimalSymbol & support for simple bullet anchoring, version-->3.1.35
robin
parents:
4130
diff
changeset
|
152 |
s = s.lower() |
16f067cf3dae
added rl_settings.decimalSymbol & support for simple bullet anchoring, version-->3.1.35
robin
parents:
4130
diff
changeset
|
153 |
if not s in ('start','middle','end','numeric'): |
16f067cf3dae
added rl_settings.decimalSymbol & support for simple bullet anchoring, version-->3.1.35
robin
parents:
4130
diff
changeset
|
154 |
raise ValueError('illegal bullet anchor %r' % s) |
16f067cf3dae
added rl_settings.decimalSymbol & support for simple bullet anchoring, version-->3.1.35
robin
parents:
4130
diff
changeset
|
155 |
return s |
119 | 156 |
|
4220
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
157 |
def _wordWrapConv(s): |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
158 |
s = s.upper().strip() |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
159 |
if not s: return None |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
160 |
if s not in ('CJK','RTL','LTR'): |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
161 |
raise ValueError('cannot convert wordWrap=%r' % s) |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
162 |
return s |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
163 |
|
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
164 |
def _textTransformConv(s): |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
165 |
s = s.lower().strip() |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
166 |
if not s: return None |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
167 |
if s not in ('uppercase','lowercase','capitalize','none'): |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
168 |
raise ValueError('cannot convert wordWrap=%r' % s) |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
169 |
return s |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
170 |
|
119 | 171 |
_paraAttrMap = {'font': ('fontName', None), |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
172 |
'face': ('fontName', None), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
173 |
'fontsize': ('fontSize', _num), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
174 |
'size': ('fontSize', _num), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
175 |
'leading': ('leading', _num), |
2836 | 176 |
'autoleading': ('autoLeading', _autoLeading), |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
177 |
'lindent': ('leftIndent', _num), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
178 |
'rindent': ('rightIndent', _num), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
179 |
'findent': ('firstLineIndent', _num), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
180 |
'align': ('alignment', _align), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
181 |
'spaceb': ('spaceBefore', _num), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
182 |
'spacea': ('spaceAfter', _num), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
183 |
'bfont': ('bulletFontName', None), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
184 |
'bfontsize': ('bulletFontSize',_num), |
2860
3f14d66194c2
platypus: added bulletOffsetY inspired by haraldarminmassa@gmail.com
rgbecker
parents:
2857
diff
changeset
|
185 |
'boffsety': ('bulletOffsetY',_num), |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
186 |
'bindent': ('bulletIndent',_num), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
187 |
'bcolor': ('bulletColor',toColor), |
4136
16f067cf3dae
added rl_settings.decimalSymbol & support for simple bullet anchoring, version-->3.1.35
robin
parents:
4130
diff
changeset
|
188 |
'banchor': ('bulletAnchor',_bAnchor), |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
189 |
'color':('textColor',toColor), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
190 |
'backcolor':('backColor',toColor), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
191 |
'bgcolor':('backColor',toColor), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
192 |
'bg':('backColor',toColor), |
1940 | 193 |
'fg': ('textColor',toColor), |
4220
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
194 |
'justifybreaks': ('justifyBreaks',_bool), |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
195 |
'justifylastline': ('justifyLastLine',_int), |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
196 |
'wordwrap': ('wordWrap',_wordWrapConv), |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
197 |
'allowwidows': ('allowWidows',_bool), |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
198 |
'alloworphans': ('allowOrphans',_bool), |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
199 |
'splitlongwords': ('splitLongWords',_bool), |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
200 |
'borderwidth': ('borderWidth',_num), |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
201 |
'borderpadding': ('borderpadding',_num), |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
202 |
'bordercolor': ('borderColor',toColor), |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
203 |
'borderradius': ('borderRadius',_num), |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
204 |
'texttransform':('textTransform',_textTransformConv), |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
205 |
'enddots':('endDots',None), |
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
206 |
'underlineproportion':('underlineProportion',_num), |
4277 | 207 |
'spaceshrinkage':('spaceShrinkage',_num), |
1940 | 208 |
} |
119 | 209 |
|
250 | 210 |
_bulletAttrMap = { |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
211 |
'font': ('bulletFontName', None), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
212 |
'face': ('bulletFontName', None), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
213 |
'size': ('bulletFontSize',_num), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
214 |
'fontsize': ('bulletFontSize',_num), |
2860
3f14d66194c2
platypus: added bulletOffsetY inspired by haraldarminmassa@gmail.com
rgbecker
parents:
2857
diff
changeset
|
215 |
'offsety': ('bulletOffsetY',_num), |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
216 |
'indent': ('bulletIndent',_num), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
217 |
'color': ('bulletColor',toColor), |
1940 | 218 |
'fg': ('bulletColor',toColor), |
4136
16f067cf3dae
added rl_settings.decimalSymbol & support for simple bullet anchoring, version-->3.1.35
robin
parents:
4130
diff
changeset
|
219 |
'anchor': ('bulletAnchor',_bAnchor), |
1940 | 220 |
} |
250 | 221 |
|
119 | 222 |
#things which are valid font attributes |
223 |
_fontAttrMap = {'size': ('fontSize', _num), |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
224 |
'face': ('fontName', None), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
225 |
'name': ('fontName', None), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
226 |
'fg': ('textColor', toColor), |
1940 | 227 |
'color':('textColor', toColor), |
2446 | 228 |
'backcolor':('backColor',toColor), |
229 |
'bgcolor':('backColor',toColor), |
|
1940 | 230 |
} |
3552
20ecbcc53c15
paraparser.py add support for <span style=stylename>
rgbecker
parents:
3440
diff
changeset
|
231 |
#things which are valid span attributes |
20ecbcc53c15
paraparser.py add support for <span style=stylename>
rgbecker
parents:
3440
diff
changeset
|
232 |
_spanAttrMap = {'size': ('fontSize', _num), |
20ecbcc53c15
paraparser.py add support for <span style=stylename>
rgbecker
parents:
3440
diff
changeset
|
233 |
'face': ('fontName', None), |
20ecbcc53c15
paraparser.py add support for <span style=stylename>
rgbecker
parents:
3440
diff
changeset
|
234 |
'name': ('fontName', None), |
20ecbcc53c15
paraparser.py add support for <span style=stylename>
rgbecker
parents:
3440
diff
changeset
|
235 |
'fg': ('textColor', toColor), |
20ecbcc53c15
paraparser.py add support for <span style=stylename>
rgbecker
parents:
3440
diff
changeset
|
236 |
'color':('textColor', toColor), |
20ecbcc53c15
paraparser.py add support for <span style=stylename>
rgbecker
parents:
3440
diff
changeset
|
237 |
'backcolor':('backColor',toColor), |
20ecbcc53c15
paraparser.py add support for <span style=stylename>
rgbecker
parents:
3440
diff
changeset
|
238 |
'bgcolor':('backColor',toColor), |
20ecbcc53c15
paraparser.py add support for <span style=stylename>
rgbecker
parents:
3440
diff
changeset
|
239 |
'style': ('style',None), |
20ecbcc53c15
paraparser.py add support for <span style=stylename>
rgbecker
parents:
3440
diff
changeset
|
240 |
} |
2575 | 241 |
#things which are valid font attributes |
242 |
_linkAttrMap = {'size': ('fontSize', _num), |
|
243 |
'face': ('fontName', None), |
|
244 |
'name': ('fontName', None), |
|
245 |
'fg': ('textColor', toColor), |
|
246 |
'color':('textColor', toColor), |
|
247 |
'backcolor':('backColor',toColor), |
|
248 |
'bgcolor':('backColor',toColor), |
|
249 |
'dest': ('link', None), |
|
250 |
'destination': ('link', None), |
|
251 |
'target': ('link', None), |
|
2594 | 252 |
'href': ('link', None), |
2575 | 253 |
} |
2744 | 254 |
_anchorAttrMap = {'fontSize': ('fontSize', _num), |
255 |
'fontName': ('fontName', None), |
|
256 |
'name': ('name', None), |
|
257 |
'fg': ('textColor', toColor), |
|
258 |
'color':('textColor', toColor), |
|
259 |
'backcolor':('backColor',toColor), |
|
260 |
'bgcolor':('backColor',toColor), |
|
261 |
'href': ('href', None), |
|
262 |
} |
|
2857
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
263 |
_imgAttrMap = { |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
264 |
'src': ('src', None), |
3434
3c14212cc997
platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents:
3368
diff
changeset
|
265 |
'width': ('width',_numpct), |
3c14212cc997
platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents:
3368
diff
changeset
|
266 |
'height':('height',_numpct), |
2857
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
267 |
'valign':('valign',_valignpc), |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
268 |
} |
3165 | 269 |
_indexAttrMap = { |
270 |
'name': ('name',None), |
|
271 |
'item': ('item',None), |
|
3187
2d5a6655556e
tableofcontents/paraparser: allow for format and offset parameters
rgbecker
parents:
3165
diff
changeset
|
272 |
'offset': ('offset',None), |
2d5a6655556e
tableofcontents/paraparser: allow for format and offset parameters
rgbecker
parents:
3165
diff
changeset
|
273 |
'format': ('format',None), |
3165 | 274 |
} |
4249
8fc7d11bdee0
add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents:
4220
diff
changeset
|
275 |
_supAttrMap = { |
4255
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
276 |
'rise': ('supr', _CheckSup('rise')), |
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
277 |
'size': ('sups', _CheckSup('size')), |
4249
8fc7d11bdee0
add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents:
4220
diff
changeset
|
278 |
} |
119 | 279 |
|
280 |
def _addAttributeNames(m): |
|
3721 | 281 |
K = list(m.keys()) |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
282 |
for k in K: |
1944 | 283 |
n = m[k][0] |
3326 | 284 |
if n not in m: m[n] = m[k] |
3731 | 285 |
n = n.lower() |
3326 | 286 |
if n not in m: m[n] = m[k] |
119 | 287 |
|
288 |
_addAttributeNames(_paraAttrMap) |
|
289 |
_addAttributeNames(_fontAttrMap) |
|
3552
20ecbcc53c15
paraparser.py add support for <span style=stylename>
rgbecker
parents:
3440
diff
changeset
|
290 |
_addAttributeNames(_spanAttrMap) |
250 | 291 |
_addAttributeNames(_bulletAttrMap) |
2747 | 292 |
_addAttributeNames(_anchorAttrMap) |
293 |
_addAttributeNames(_linkAttrMap) |
|
119 | 294 |
|
295 |
def _applyAttributes(obj, attr): |
|
3723
99aa837b6703
second stage of port to Python 3.3; working hello world
rptlab
parents:
3721
diff
changeset
|
296 |
for k, v in attr.items(): |
3787
8f9be6d6f75c
convert paraparser to use pyRXP directly (or any TT producer)
robin
parents:
3731
diff
changeset
|
297 |
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
|
298 |
if hasattr(obj, k): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
299 |
v = v[1]+getattr(obj,k) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
300 |
else: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
301 |
v = v[1] |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
302 |
setattr(obj,k,v) |
102 | 303 |
|
1931
784fce255e2d
Added in more special entities as suggested by Christoph Zwerschke
rgbecker
parents:
1736
diff
changeset
|
304 |
#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
|
305 |
#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
|
306 |
#numeric entity names that follow. |
96 | 307 |
greeks = { |
3957
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
308 |
'Aacute': u'\xc1', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
309 |
'aacute': u'\xe1', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
310 |
'Acirc': u'\xc2', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
311 |
'acirc': u'\xe2', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
312 |
'acute': u'\xb4', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
313 |
'AElig': u'\xc6', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
314 |
'aelig': u'\xe6', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
315 |
'Agrave': u'\xc0', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
316 |
'agrave': u'\xe0', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
317 |
'alefsym': u'\u2135', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
318 |
'Alpha': u'\u0391', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
319 |
'alpha': u'\u03b1', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
320 |
'and': u'\u2227', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
321 |
'ang': u'\u2220', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
322 |
'Aring': u'\xc5', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
323 |
'aring': u'\xe5', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
324 |
'asymp': u'\u2248', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
325 |
'Atilde': u'\xc3', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
326 |
'atilde': u'\xe3', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
327 |
'Auml': u'\xc4', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
328 |
'auml': u'\xe4', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
329 |
'bdquo': u'\u201e', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
330 |
'Beta': u'\u0392', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
331 |
'beta': u'\u03b2', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
332 |
'brvbar': u'\xa6', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
333 |
'bull': u'\u2022', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
334 |
'cap': u'\u2229', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
335 |
'Ccedil': u'\xc7', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
336 |
'ccedil': u'\xe7', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
337 |
'cedil': u'\xb8', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
338 |
'cent': u'\xa2', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
339 |
'Chi': u'\u03a7', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
340 |
'chi': u'\u03c7', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
341 |
'circ': u'\u02c6', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
342 |
'clubs': u'\u2663', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
343 |
'cong': u'\u2245', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
344 |
'copy': u'\xa9', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
345 |
'crarr': u'\u21b5', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
346 |
'cup': u'\u222a', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
347 |
'curren': u'\xa4', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
348 |
'dagger': u'\u2020', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
349 |
'Dagger': u'\u2021', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
350 |
'darr': u'\u2193', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
351 |
'dArr': u'\u21d3', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
352 |
'deg': u'\xb0', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
353 |
'delta': u'\u03b4', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
354 |
'Delta': u'\u2206', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
355 |
'diams': u'\u2666', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
356 |
'divide': u'\xf7', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
357 |
'Eacute': u'\xc9', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
358 |
'eacute': u'\xe9', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
359 |
'Ecirc': u'\xca', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
360 |
'ecirc': u'\xea', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
361 |
'Egrave': u'\xc8', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
362 |
'egrave': u'\xe8', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
363 |
'empty': u'\u2205', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
364 |
'emsp': u'\u2003', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
365 |
'ensp': u'\u2002', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
366 |
'Epsilon': u'\u0395', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
367 |
'epsilon': u'\u03b5', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
368 |
'epsiv': u'\u03b5', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
369 |
'equiv': u'\u2261', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
370 |
'Eta': u'\u0397', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
371 |
'eta': u'\u03b7', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
372 |
'ETH': u'\xd0', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
373 |
'eth': u'\xf0', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
374 |
'Euml': u'\xcb', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
375 |
'euml': u'\xeb', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
376 |
'euro': u'\u20ac', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
377 |
'exist': u'\u2203', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
378 |
'fnof': u'\u0192', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
379 |
'forall': u'\u2200', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
380 |
'frac12': u'\xbd', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
381 |
'frac14': u'\xbc', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
382 |
'frac34': u'\xbe', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
383 |
'frasl': u'\u2044', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
384 |
'Gamma': u'\u0393', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
385 |
'gamma': u'\u03b3', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
386 |
'ge': u'\u2265', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
387 |
'harr': u'\u2194', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
388 |
'hArr': u'\u21d4', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
389 |
'hearts': u'\u2665', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
390 |
'hellip': u'\u2026', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
391 |
'Iacute': u'\xcd', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
392 |
'iacute': u'\xed', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
393 |
'Icirc': u'\xce', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
394 |
'icirc': u'\xee', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
395 |
'iexcl': u'\xa1', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
396 |
'Igrave': u'\xcc', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
397 |
'igrave': u'\xec', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
398 |
'image': u'\u2111', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
399 |
'infin': u'\u221e', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
400 |
'int': u'\u222b', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
401 |
'Iota': u'\u0399', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
402 |
'iota': u'\u03b9', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
403 |
'iquest': u'\xbf', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
404 |
'isin': u'\u2208', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
405 |
'Iuml': u'\xcf', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
406 |
'iuml': u'\xef', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
407 |
'Kappa': u'\u039a', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
408 |
'kappa': u'\u03ba', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
409 |
'Lambda': u'\u039b', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
410 |
'lambda': u'\u03bb', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
411 |
'lang': u'\u2329', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
412 |
'laquo': u'\xab', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
413 |
'larr': u'\u2190', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
414 |
'lArr': u'\u21d0', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
415 |
'lceil': u'\uf8ee', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
416 |
'ldquo': u'\u201c', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
417 |
'le': u'\u2264', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
418 |
'lfloor': u'\uf8f0', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
419 |
'lowast': u'\u2217', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
420 |
'loz': u'\u25ca', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
421 |
'lrm': u'\u200e', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
422 |
'lsaquo': u'\u2039', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
423 |
'lsquo': u'\u2018', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
424 |
'macr': u'\xaf', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
425 |
'mdash': u'\u2014', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
426 |
'micro': u'\xb5', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
427 |
'middot': u'\xb7', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
428 |
'minus': u'\u2212', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
429 |
'mu': u'\xb5', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
430 |
'Mu': u'\u039c', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
431 |
'nabla': u'\u2207', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
432 |
'nbsp': u'\xa0', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
433 |
'ndash': u'\u2013', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
434 |
'ne': u'\u2260', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
435 |
'ni': u'\u220b', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
436 |
'notin': u'\u2209', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
437 |
'not': u'\xac', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
438 |
'nsub': u'\u2284', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
439 |
'Ntilde': u'\xd1', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
440 |
'ntilde': u'\xf1', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
441 |
'Nu': u'\u039d', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
442 |
'nu': u'\u03bd', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
443 |
'Oacute': u'\xd3', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
444 |
'oacute': u'\xf3', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
445 |
'Ocirc': u'\xd4', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
446 |
'ocirc': u'\xf4', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
447 |
'OElig': u'\u0152', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
448 |
'oelig': u'\u0153', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
449 |
'Ograve': u'\xd2', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
450 |
'ograve': u'\xf2', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
451 |
'oline': u'\uf8e5', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
452 |
'omega': u'\u03c9', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
453 |
'Omega': u'\u2126', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
454 |
'Omicron': u'\u039f', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
455 |
'omicron': u'\u03bf', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
456 |
'oplus': u'\u2295', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
457 |
'ordf': u'\xaa', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
458 |
'ordm': u'\xba', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
459 |
'or': u'\u2228', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
460 |
'Oslash': u'\xd8', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
461 |
'oslash': u'\xf8', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
462 |
'Otilde': u'\xd5', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
463 |
'otilde': u'\xf5', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
464 |
'otimes': u'\u2297', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
465 |
'Ouml': u'\xd6', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
466 |
'ouml': u'\xf6', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
467 |
'para': u'\xb6', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
468 |
'part': u'\u2202', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
469 |
'permil': u'\u2030', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
470 |
'perp': u'\u22a5', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
471 |
'phis': u'\u03c6', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
472 |
'Phi': u'\u03a6', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
473 |
'phi': u'\u03d5', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
474 |
'piv': u'\u03d6', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
475 |
'Pi': u'\u03a0', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
476 |
'pi': u'\u03c0', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
477 |
'plusmn': u'\xb1', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
478 |
'pound': u'\xa3', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
479 |
'prime': u'\u2032', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
480 |
'Prime': u'\u2033', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
481 |
'prod': u'\u220f', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
482 |
'prop': u'\u221d', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
483 |
'Psi': u'\u03a8', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
484 |
'psi': u'\u03c8', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
485 |
'radic': u'\u221a', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
486 |
'rang': u'\u232a', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
487 |
'raquo': u'\xbb', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
488 |
'rarr': u'\u2192', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
489 |
'rArr': u'\u21d2', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
490 |
'rceil': u'\uf8f9', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
491 |
'rdquo': u'\u201d', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
492 |
'real': u'\u211c', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
493 |
'reg': u'\xae', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
494 |
'rfloor': u'\uf8fb', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
495 |
'Rho': u'\u03a1', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
496 |
'rho': u'\u03c1', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
497 |
'rlm': u'\u200f', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
498 |
'rsaquo': u'\u203a', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
499 |
'rsquo': u'\u2019', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
500 |
'sbquo': u'\u201a', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
501 |
'Scaron': u'\u0160', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
502 |
'scaron': u'\u0161', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
503 |
'sdot': u'\u22c5', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
504 |
'sect': u'\xa7', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
505 |
'shy': u'\xad', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
506 |
'sigmaf': u'\u03c2', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
507 |
'sigmav': u'\u03c2', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
508 |
'Sigma': u'\u03a3', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
509 |
'sigma': u'\u03c3', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
510 |
'sim': u'\u223c', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
511 |
'spades': u'\u2660', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
512 |
'sube': u'\u2286', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
513 |
'sub': u'\u2282', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
514 |
'sum': u'\u2211', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
515 |
'sup1': u'\xb9', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
516 |
'sup2': u'\xb2', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
517 |
'sup3': u'\xb3', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
518 |
'supe': u'\u2287', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
519 |
'sup': u'\u2283', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
520 |
'szlig': u'\xdf', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
521 |
'Tau': u'\u03a4', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
522 |
'tau': u'\u03c4', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
523 |
'there4': u'\u2234', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
524 |
'thetasym': u'\u03d1', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
525 |
'thetav': u'\u03d1', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
526 |
'Theta': u'\u0398', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
527 |
'theta': u'\u03b8', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
528 |
'thinsp': u'\u2009', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
529 |
'THORN': u'\xde', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
530 |
'thorn': u'\xfe', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
531 |
'tilde': u'\u02dc', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
532 |
'times': u'\xd7', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
533 |
'trade': u'\uf8ea', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
534 |
'Uacute': u'\xda', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
535 |
'uacute': u'\xfa', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
536 |
'uarr': u'\u2191', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
537 |
'uArr': u'\u21d1', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
538 |
'Ucirc': u'\xdb', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
539 |
'ucirc': u'\xfb', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
540 |
'Ugrave': u'\xd9', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
541 |
'ugrave': u'\xf9', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
542 |
'uml': u'\xa8', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
543 |
'upsih': u'\u03d2', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
544 |
'Upsilon': u'\u03a5', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
545 |
'upsilon': u'\u03c5', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
546 |
'Uuml': u'\xdc', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
547 |
'uuml': u'\xfc', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
548 |
'weierp': u'\u2118', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
549 |
'Xi': u'\u039e', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
550 |
'xi': u'\u03be', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
551 |
'Yacute': u'\xdd', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
552 |
'yacute': u'\xfd', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
553 |
'yen': u'\xa5', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
554 |
'yuml': u'\xff', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
555 |
'Yuml': u'\u0178', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
556 |
'Zeta': u'\u0396', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
557 |
'zeta': u'\u03b6', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
558 |
'zwj': u'\u200d', |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
559 |
'zwnj': u'\u200c', |
1931
784fce255e2d
Added in more special entities as suggested by Christoph Zwerschke
rgbecker
parents:
1736
diff
changeset
|
560 |
} |
96 | 561 |
|
4004 | 562 |
known_entities = dict([(k,uniChr(v)) for k,v in name2codepoint.items()]) |
3957
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
563 |
for k in greeks: |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
564 |
if k not in known_entities: |
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
565 |
known_entities[k] = greeks[k] |
3994 | 566 |
f = isPy3 and asBytes or asUnicode |
567 |
K = list(known_entities.keys()) |
|
568 |
for k in K: |
|
569 |
known_entities[f(k)] = known_entities[k] |
|
570 |
del k, f, K |
|
3957
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
571 |
|
96 | 572 |
#------------------------------------------------------------------------ |
518 | 573 |
class ParaFrag(ABag): |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
574 |
"""class ParaFrag contains the intermediate representation of string |
3961 | 575 |
segments as they are being parsed by the ParaParser. |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
576 |
fontname, fontSize, rise, textColor, cbDefn |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
577 |
""" |
96 | 578 |
|
2584
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
579 |
_greek2Utf8=None |
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
580 |
def _greekConvert(data): |
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
581 |
global _greek2Utf8 |
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
582 |
if not _greek2Utf8: |
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
583 |
from reportlab.pdfbase.rl_codecs import RL_Codecs |
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
584 |
import codecs |
3812 | 585 |
#our decoding map |
586 |
dm = codecs.make_identity_dict(range(32,256)) |
|
3721 | 587 |
for k in range(0,32): |
2584
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
588 |
dm[k] = None |
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
589 |
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
|
590 |
_greek2Utf8 = {} |
3721 | 591 |
for k,v in dm.items(): |
2584
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
592 |
if not v: |
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
593 |
u = '\0' |
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
594 |
else: |
3787
8f9be6d6f75c
convert paraparser to use pyRXP directly (or any TT producer)
robin
parents:
3731
diff
changeset
|
595 |
if isPy3: |
8f9be6d6f75c
convert paraparser to use pyRXP directly (or any TT producer)
robin
parents:
3731
diff
changeset
|
596 |
u = chr(v) |
8f9be6d6f75c
convert paraparser to use pyRXP directly (or any TT producer)
robin
parents:
3731
diff
changeset
|
597 |
else: |
3900 | 598 |
u = unichr(v).encode('utf8') |
2584
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
599 |
_greek2Utf8[chr(k)] = u |
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
600 |
return ''.join(map(_greek2Utf8.__getitem__,data)) |
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
601 |
|
96 | 602 |
#------------------------------------------------------------------ |
267
52a348f6c4c3
noted replication of XML markup comment between paraparser.py and paragraph.py
aaron_watters
parents:
266
diff
changeset
|
603 |
# !!! 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
|
604 |
# The ParaFormatter will be able to format the following |
96 | 605 |
# tags: |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
606 |
# < /b > - bold |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
607 |
# < /i > - italics |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
608 |
# < u > < /u > - underline |
2644 | 609 |
# < strike > < /strike > - strike through |
4249
8fc7d11bdee0
add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents:
4220
diff
changeset
|
610 |
# < super [size="pts"] [rise="pts"]> < /super > - superscript |
8fc7d11bdee0
add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents:
4220
diff
changeset
|
611 |
# < sup ="pts"] [rise="pts"]> < /sup > - superscript |
8fc7d11bdee0
add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents:
4220
diff
changeset
|
612 |
# < sub ="pts"] [rise="pts"]> < /sub > - subscript |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
613 |
# <font name=fontfamily/fontname color=colorname size=float> |
3552
20ecbcc53c15
paraparser.py add support for <span style=stylename>
rgbecker
parents:
3440
diff
changeset
|
614 |
# <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
|
615 |
# < bullet > </bullet> - bullet text (at head of para only) |
3165 | 616 |
# <onDraw name=callable label="a label"/> |
617 |
# <index [name="callablecanvasattribute"] label="a label"/> |
|
2670 | 618 |
# <link>link text</link> |
619 |
# attributes of links |
|
620 |
# size/fontSize=num |
|
621 |
# name/face/fontName=name |
|
622 |
# fg/textColor/color=color |
|
623 |
# backcolor/backColor/bgcolor=color |
|
624 |
# dest/destination/target/href/link=target |
|
2745 | 625 |
# <a>anchor text</a> |
2744 | 626 |
# attributes of anchors |
627 |
# fontSize=num |
|
628 |
# fontName=name |
|
629 |
# fg/textColor/color=color |
|
630 |
# backcolor/backColor/bgcolor=color |
|
631 |
# href=href |
|
632 |
# <a name="anchorpoint"/> |
|
2584
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
633 |
# <unichar name="unicode character name"/> |
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
634 |
# <unichar value="unicode code point"/> |
2857
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
635 |
# <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
|
636 |
# 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
|
637 |
# 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
|
638 |
# <greek> - </greek> |
1683 | 639 |
# |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
640 |
# The whole may be surrounded by <para> </para> tags |
119 | 641 |
# |
96 | 642 |
# It will also be able to handle any MathML specified Greek characters. |
643 |
#------------------------------------------------------------------ |
|
3954
44dbe56eb858
first attempt at HTMLParser-based paraparser
Andy Robinson <andy@reportlab.com>
parents:
3937
diff
changeset
|
644 |
class ParaParser(HTMLParser): |
96 | 645 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
646 |
#---------------------------------------------------------- |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
647 |
# 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
|
648 |
# |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
649 |
# start_<tag>(attributes) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
650 |
# end_<tag>() |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
651 |
# |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
652 |
# 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
|
653 |
# 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
|
654 |
# 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
|
655 |
# 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
|
656 |
# 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
|
657 |
# 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
|
658 |
#---------------------------------------------------------- |
96 | 659 |
|
1940 | 660 |
def __getattr__( self, attrName ): |
661 |
"""This way we can handle <TAG> the same way as <tag> (ignoring case).""" |
|
2369 | 662 |
if attrName!=attrName.lower() and attrName!="caseSensitive" and not self.caseSensitive and \ |
663 |
(attrName.startswith("start_") or attrName.startswith("end_")): |
|
664 |
return getattr(self,attrName.lower()) |
|
3721 | 665 |
raise AttributeError(attrName) |
1940 | 666 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
667 |
#### bold |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
668 |
def start_b( self, attributes ): |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
669 |
self._push('b',bold=1) |
96 | 670 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
671 |
def end_b( self ): |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
672 |
self._pop('b') |
96 | 673 |
|
1940 | 674 |
def start_strong( self, attributes ): |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
675 |
self._push('strong',bold=1) |
1940 | 676 |
|
677 |
def end_strong( self ): |
|
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
678 |
self._pop('strong') |
1940 | 679 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
680 |
#### italics |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
681 |
def start_i( self, attributes ): |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
682 |
self._push('i',italic=1) |
96 | 683 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
684 |
def end_i( self ): |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
685 |
self._pop('i') |
96 | 686 |
|
1940 | 687 |
def start_em( self, attributes ): |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
688 |
self._push('em', italic=1) |
1940 | 689 |
|
690 |
def end_em( self ): |
|
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
691 |
self._pop('em') |
1940 | 692 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
693 |
#### underline |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
694 |
def start_u( self, attributes ): |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
695 |
self._push('u',underline=1) |
96 | 696 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
697 |
def end_u( self ): |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
698 |
self._pop('u') |
96 | 699 |
|
2644 | 700 |
#### strike |
701 |
def start_strike( self, attributes ): |
|
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
702 |
self._push('strike',strike=1) |
2644 | 703 |
|
704 |
def end_strike( self ): |
|
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
705 |
self._pop('strike') |
2644 | 706 |
|
2575 | 707 |
#### link |
708 |
def start_link(self, attributes): |
|
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
709 |
self._push('link',**self.getAttributes(attributes,_linkAttrMap)) |
2575 | 710 |
|
711 |
def end_link(self): |
|
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
712 |
if self._pop('link').link is None: |
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
713 |
raise ValueError('<link> has no target or href') |
2575 | 714 |
|
2744 | 715 |
#### anchor |
716 |
def start_a(self, attributes): |
|
717 |
A = self.getAttributes(attributes,_anchorAttrMap) |
|
2893
7432e06445ba
paraparser.py: improved checking on <a> tag attributes
rgbecker
parents:
2861
diff
changeset
|
718 |
name = A.get('name',None) |
7432e06445ba
paraparser.py: improved checking on <a> tag attributes
rgbecker
parents:
2861
diff
changeset
|
719 |
if name is not None: |
7432e06445ba
paraparser.py: improved checking on <a> tag attributes
rgbecker
parents:
2861
diff
changeset
|
720 |
name = name.strip() |
7432e06445ba
paraparser.py: improved checking on <a> tag attributes
rgbecker
parents:
2861
diff
changeset
|
721 |
if not name: |
7432e06445ba
paraparser.py: improved checking on <a> tag attributes
rgbecker
parents:
2861
diff
changeset
|
722 |
self._syntax_error('<a name="..."/> anchor variant requires non-blank name') |
2744 | 723 |
if len(A)>1: |
724 |
self._syntax_error('<a name="..."/> anchor variant only allows name attribute') |
|
725 |
A = dict(name=A['name']) |
|
726 |
A['_selfClosingTag'] = 'anchor' |
|
727 |
else: |
|
2893
7432e06445ba
paraparser.py: improved checking on <a> tag attributes
rgbecker
parents:
2861
diff
changeset
|
728 |
href = A.get('href','').strip() |
7432e06445ba
paraparser.py: improved checking on <a> tag attributes
rgbecker
parents:
2861
diff
changeset
|
729 |
A['link'] = href #convert to our link form |
3931 | 730 |
A.pop('href',None) |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
731 |
self._push('a',**A) |
2744 | 732 |
|
733 |
def end_a(self): |
|
734 |
frag = self._stack[-1] |
|
735 |
sct = getattr(frag,'_selfClosingTag','') |
|
736 |
if sct: |
|
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
737 |
if not (sct=='anchor' and frag.name): |
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
738 |
raise ValueError('Parser failure in <a/>') |
2744 | 739 |
defn = frag.cbDefn = ABag() |
740 |
defn.label = defn.kind = 'anchor' |
|
741 |
defn.name = frag.name |
|
742 |
del frag.name, frag._selfClosingTag |
|
743 |
self.handle_data('') |
|
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
744 |
self._pop('a') |
2744 | 745 |
else: |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
746 |
if self._pop('a').link is None: |
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
747 |
raise ValueError('<link> has no href') |
2742 | 748 |
|
2857
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
749 |
def start_img(self,attributes): |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
750 |
A = self.getAttributes(attributes,_imgAttrMap) |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
751 |
if not A.get('src'): |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
752 |
self._syntax_error('<img> needs src attribute') |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
753 |
A['_selfClosingTag'] = 'img' |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
754 |
self._push('img',**A) |
2857
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
755 |
|
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
756 |
def end_img(self): |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
757 |
frag = self._stack[-1] |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
758 |
if not getattr(frag,'_selfClosingTag',''): |
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
759 |
raise ValueError('Parser failure in <img/>') |
2857
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
760 |
defn = frag.cbDefn = ABag() |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
761 |
defn.kind = 'img' |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
762 |
defn.src = getattr(frag,'src',None) |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
763 |
defn.image = ImageReader(defn.src) |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
764 |
size = defn.image.getSize() |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
765 |
defn.width = getattr(frag,'width',size[0]) |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
766 |
defn.height = getattr(frag,'height',size[1]) |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
767 |
defn.valign = getattr(frag,'valign','bottom') |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
768 |
del frag._selfClosingTag |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
769 |
self.handle_data('') |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
770 |
self._pop('img') |
2857
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
771 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
772 |
#### super script |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
773 |
def start_super( self, attributes ): |
4249
8fc7d11bdee0
add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents:
4220
diff
changeset
|
774 |
A = self.getAttributes(attributes,_supAttrMap) |
8fc7d11bdee0
add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents:
4220
diff
changeset
|
775 |
A['sup']=1 |
8fc7d11bdee0
add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents:
4220
diff
changeset
|
776 |
self._push('super',**A) |
96 | 777 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
778 |
def end_super( self ): |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
779 |
self._pop('super') |
96 | 780 |
|
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
781 |
def start_sup( self, attributes ): |
4249
8fc7d11bdee0
add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents:
4220
diff
changeset
|
782 |
A = self.getAttributes(attributes,_supAttrMap) |
8fc7d11bdee0
add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents:
4220
diff
changeset
|
783 |
A['sup']=1 |
8fc7d11bdee0
add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents:
4220
diff
changeset
|
784 |
self._push('sup',**A) |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
785 |
|
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
786 |
def end_sup( self ): |
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
787 |
self._pop('sup') |
1736 | 788 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
789 |
#### sub script |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
790 |
def start_sub( self, attributes ): |
4249
8fc7d11bdee0
add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents:
4220
diff
changeset
|
791 |
A = self.getAttributes(attributes,_supAttrMap) |
8fc7d11bdee0
add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents:
4220
diff
changeset
|
792 |
A['sub']=1 |
8fc7d11bdee0
add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents:
4220
diff
changeset
|
793 |
self._push('sub',**A) |
96 | 794 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
795 |
def end_sub( self ): |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
796 |
self._pop('sub') |
96 | 797 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
798 |
#### greek script |
2376 | 799 |
#### add symbol encoding |
800 |
def handle_charref(self, name): |
|
801 |
try: |
|
2575 | 802 |
if name[0]=='x': |
803 |
n = int(name[1:],16) |
|
1931
784fce255e2d
Added in more special entities as suggested by Christoph Zwerschke
rgbecker
parents:
1736
diff
changeset
|
804 |
else: |
2575 | 805 |
n = int(name) |
806 |
except ValueError: |
|
2376 | 807 |
self.unknown_charref(name) |
808 |
return |
|
4004 | 809 |
self.handle_data(uniChr(n)) #.encode('utf8')) |
134 | 810 |
|
2376 | 811 |
def syntax_error(self,lineno,message): |
812 |
self._syntax_error(message) |
|
134 | 813 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
814 |
def _syntax_error(self,message): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
815 |
if message[:10]=="attribute " and message[-17:]==" value not quoted": return |
4255
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
816 |
if self._crashOnError: |
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
817 |
raise ValueError('paraparser: syntax error: %s' % message) |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
818 |
self.errors.append(message) |
134 | 819 |
|
2584
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
820 |
def start_greek(self, attr): |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
821 |
self._push('greek',greek=1) |
96 | 822 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
823 |
def end_greek(self): |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
824 |
self._pop('greek') |
96 | 825 |
|
2584
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
826 |
def start_unichar(self, attr): |
3326 | 827 |
if 'name' in attr: |
828 |
if 'code' in attr: |
|
2584
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
829 |
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
|
830 |
try: |
3809 | 831 |
v = unicodedata.lookup(attr['name']) |
2584
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
832 |
except KeyError: |
4116
cf49463fc067
Fix a bunch of undefined names. Mostly typos or missing imports.
Matthew Duggan <mgithub@guarana.org>
parents:
4097
diff
changeset
|
833 |
self._syntax_error('<unichar/> invalid name attribute\n"%s"' % ascii(attr['name'])) |
2584
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
834 |
v = '\0' |
3326 | 835 |
elif 'code' in attr: |
2584
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
836 |
try: |
3937 | 837 |
v = int(eval(attr['code'])) |
838 |
v = chr(v) if isPy3 else unichr(v) |
|
2584
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
839 |
except: |
3809 | 840 |
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
|
841 |
v = '\0' |
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
842 |
else: |
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
843 |
v = None |
2664 | 844 |
if attr: |
3721 | 845 |
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
|
846 |
|
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
847 |
if v is not None: |
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
848 |
self.handle_data(v) |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
849 |
self._push('unichar',_selfClosingTag='unichar') |
2584
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
850 |
|
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
851 |
def end_unichar(self): |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
852 |
self._pop('unichar') |
2584
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
853 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
854 |
def start_font(self,attr): |
4129
1266500a2c22
paraparser.py: fix handling of fontName attributes in span/font; version-->3.1.29
robin
parents:
4116
diff
changeset
|
855 |
A = self.getAttributes(attr,_spanAttrMap) |
1266500a2c22
paraparser.py: fix handling of fontName attributes in span/font; version-->3.1.29
robin
parents:
4116
diff
changeset
|
856 |
if 'fontName' in A: |
1266500a2c22
paraparser.py: fix handling of fontName attributes in span/font; version-->3.1.29
robin
parents:
4116
diff
changeset
|
857 |
A['fontName'], A['bold'], A['italic'] = ps2tt(A['fontName']) |
4130
49161ce56cad
paraparser.py: fix handling of fontName attributes in <font> tag
robin
parents:
4129
diff
changeset
|
858 |
self._push('font',**A) |
96 | 859 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
860 |
def end_font(self): |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
861 |
self._pop('font') |
96 | 862 |
|
3552
20ecbcc53c15
paraparser.py add support for <span style=stylename>
rgbecker
parents:
3440
diff
changeset
|
863 |
def start_span(self,attr): |
20ecbcc53c15
paraparser.py add support for <span style=stylename>
rgbecker
parents:
3440
diff
changeset
|
864 |
A = self.getAttributes(attr,_spanAttrMap) |
20ecbcc53c15
paraparser.py add support for <span style=stylename>
rgbecker
parents:
3440
diff
changeset
|
865 |
if 'style' in A: |
20ecbcc53c15
paraparser.py add support for <span style=stylename>
rgbecker
parents:
3440
diff
changeset
|
866 |
style = self.findSpanStyle(A.pop('style')) |
20ecbcc53c15
paraparser.py add support for <span style=stylename>
rgbecker
parents:
3440
diff
changeset
|
867 |
D = {} |
20ecbcc53c15
paraparser.py add support for <span style=stylename>
rgbecker
parents:
3440
diff
changeset
|
868 |
for k in 'fontName fontSize textColor backColor'.split(): |
20ecbcc53c15
paraparser.py add support for <span style=stylename>
rgbecker
parents:
3440
diff
changeset
|
869 |
v = getattr(style,k,self) |
20ecbcc53c15
paraparser.py add support for <span style=stylename>
rgbecker
parents:
3440
diff
changeset
|
870 |
if v is self: continue |
20ecbcc53c15
paraparser.py add support for <span style=stylename>
rgbecker
parents:
3440
diff
changeset
|
871 |
D[k] = v |
20ecbcc53c15
paraparser.py add support for <span style=stylename>
rgbecker
parents:
3440
diff
changeset
|
872 |
D.update(A) |
20ecbcc53c15
paraparser.py add support for <span style=stylename>
rgbecker
parents:
3440
diff
changeset
|
873 |
A = D |
4129
1266500a2c22
paraparser.py: fix handling of fontName attributes in span/font; version-->3.1.29
robin
parents:
4116
diff
changeset
|
874 |
if 'fontName' in A: |
1266500a2c22
paraparser.py: fix handling of fontName attributes in span/font; version-->3.1.29
robin
parents:
4116
diff
changeset
|
875 |
A['fontName'], A['bold'], A['italic'] = ps2tt(A['fontName']) |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
876 |
self._push('span',**A) |
3552
20ecbcc53c15
paraparser.py add support for <span style=stylename>
rgbecker
parents:
3440
diff
changeset
|
877 |
|
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
878 |
def end_span(self): |
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
879 |
self._pop('span') |
3552
20ecbcc53c15
paraparser.py add support for <span style=stylename>
rgbecker
parents:
3440
diff
changeset
|
880 |
|
2663 | 881 |
def start_br(self, attr): |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
882 |
self._push('br',_selfClosingTag='br',lineBreak=True,text='') |
3954
44dbe56eb858
first attempt at HTMLParser-based paraparser
Andy Robinson <andy@reportlab.com>
parents:
3937
diff
changeset
|
883 |
|
2663 | 884 |
def end_br(self): |
3954
44dbe56eb858
first attempt at HTMLParser-based paraparser
Andy Robinson <andy@reportlab.com>
parents:
3937
diff
changeset
|
885 |
#print('\nend_br called, %d frags in list' % len(self.fragList)) |
2664 | 886 |
frag = self._stack[-1] |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
887 |
if not (frag._selfClosingTag=='br' and frag.lineBreak): |
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
888 |
raise ValueError('Parser failure in <br/>') |
2664 | 889 |
del frag._selfClosingTag |
890 |
self.handle_data('') |
|
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
891 |
self._pop('br') |
2663 | 892 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
893 |
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
|
894 |
style = self._style |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
895 |
if attr!={}: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
896 |
style = copy.deepcopy(style) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
897 |
_applyAttributes(style,self.getAttributes(attr,attrMap)) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
898 |
self._style = style |
119 | 899 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
900 |
# initialize semantic values |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
901 |
frag = ParaFrag() |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
902 |
frag.sub = 0 |
4249
8fc7d11bdee0
add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents:
4220
diff
changeset
|
903 |
frag.sup = 0 |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
904 |
frag.rise = 0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
905 |
frag.underline = 0 |
2644 | 906 |
frag.strike = 0 |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
907 |
frag.greek = 0 |
2575 | 908 |
frag.link = None |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
909 |
if bullet: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
910 |
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
|
911 |
frag.fontSize = style.bulletFontSize |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
912 |
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
|
913 |
else: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
914 |
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
|
915 |
frag.fontSize = style.fontSize |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
916 |
frag.textColor = style.textColor |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
917 |
return frag |
250 | 918 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
919 |
def start_para(self,attr): |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
920 |
frag = self._initial_frag(attr,_paraAttrMap) |
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
921 |
frag.__tag__ = 'para' |
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
922 |
self._stack = [frag] |
119 | 923 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
924 |
def end_para(self): |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
925 |
self._pop('para') |
119 | 926 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
927 |
def start_bullet(self,attr): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
928 |
if hasattr(self,'bFragList'): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
929 |
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
|
930 |
self.bFragList = [] |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
931 |
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
|
932 |
frag.isBullet = 1 |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
933 |
frag.__tag__ = 'bullet' |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
934 |
self._stack.append(frag) |
250 | 935 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
936 |
def end_bullet(self): |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
937 |
self._pop('bullet') |
250 | 938 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
939 |
#--------------------------------------------------------------- |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
940 |
def start_seqdefault(self, attr): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
941 |
try: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
942 |
default = attr['id'] |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
943 |
except KeyError: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
944 |
default = None |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
945 |
self._seq.setDefaultCounter(default) |
266 | 946 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
947 |
def end_seqdefault(self): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
948 |
pass |
1683 | 949 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
950 |
def start_seqreset(self, attr): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
951 |
try: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
952 |
id = attr['id'] |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
953 |
except KeyError: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
954 |
id = None |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
955 |
try: |
2368 | 956 |
base = int(attr['base']) |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
957 |
except: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
958 |
base=0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
959 |
self._seq.reset(id, base) |
266 | 960 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
961 |
def end_seqreset(self): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
962 |
pass |
744
2abd99baf95b
Accepts seqdefault/seqDefault and seqreset/seqReset
andy_robinson
parents:
677
diff
changeset
|
963 |
|
2368 | 964 |
def start_seqchain(self, attr): |
965 |
try: |
|
966 |
order = attr['order'] |
|
967 |
except KeyError: |
|
968 |
order = '' |
|
969 |
order = order.split() |
|
970 |
seq = self._seq |
|
971 |
for p,c in zip(order[:-1],order[1:]): |
|
972 |
seq.chain(p, c) |
|
973 |
end_seqchain = end_seqreset |
|
974 |
||
975 |
def start_seqformat(self, attr): |
|
976 |
try: |
|
977 |
id = attr['id'] |
|
978 |
except KeyError: |
|
979 |
id = None |
|
980 |
try: |
|
981 |
value = attr['value'] |
|
982 |
except KeyError: |
|
983 |
value = '1' |
|
984 |
self._seq.setFormat(id,value) |
|
985 |
end_seqformat = end_seqreset |
|
986 |
||
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
987 |
# 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
|
988 |
# the above ones should be deprecated over time. 2001-03-22 |
2368 | 989 |
start_seqDefault = start_seqdefault |
990 |
end_seqDefault = end_seqdefault |
|
991 |
start_seqReset = start_seqreset |
|
992 |
end_seqReset = end_seqreset |
|
993 |
start_seqChain = start_seqchain |
|
994 |
end_seqChain = end_seqchain |
|
995 |
start_seqFormat = start_seqformat |
|
996 |
end_seqFormat = end_seqformat |
|
1683 | 997 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
998 |
def start_seq(self, attr): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
999 |
#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
|
1000 |
#otherwise take default sequence |
3326 | 1001 |
if 'template' in attr: |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1002 |
templ = attr['template'] |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1003 |
self.handle_data(templ % self._seq) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1004 |
return |
3326 | 1005 |
elif 'id' in attr: |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1006 |
id = attr['id'] |
1683 | 1007 |
else: |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1008 |
id = None |
2694
dd0ea6474ea0
fixes to crashing PTO trailer when empty, and numbering
andy
parents:
2693
diff
changeset
|
1009 |
increment = attr.get('inc', None) |
dd0ea6474ea0
fixes to crashing PTO trailer when empty, and numbering
andy
parents:
2693
diff
changeset
|
1010 |
if not increment: |
dd0ea6474ea0
fixes to crashing PTO trailer when empty, and numbering
andy
parents:
2693
diff
changeset
|
1011 |
output = self._seq.nextf(id) |
dd0ea6474ea0
fixes to crashing PTO trailer when empty, and numbering
andy
parents:
2693
diff
changeset
|
1012 |
else: |
dd0ea6474ea0
fixes to crashing PTO trailer when empty, and numbering
andy
parents:
2693
diff
changeset
|
1013 |
#accepts "no" for do not increment, or an integer. |
dd0ea6474ea0
fixes to crashing PTO trailer when empty, and numbering
andy
parents:
2693
diff
changeset
|
1014 |
#thus, 0 and 1 increment by the right amounts. |
dd0ea6474ea0
fixes to crashing PTO trailer when empty, and numbering
andy
parents:
2693
diff
changeset
|
1015 |
if increment.lower() == 'no': |
dd0ea6474ea0
fixes to crashing PTO trailer when empty, and numbering
andy
parents:
2693
diff
changeset
|
1016 |
output = self._seq.thisf(id) |
dd0ea6474ea0
fixes to crashing PTO trailer when empty, and numbering
andy
parents:
2693
diff
changeset
|
1017 |
else: |
dd0ea6474ea0
fixes to crashing PTO trailer when empty, and numbering
andy
parents:
2693
diff
changeset
|
1018 |
incr = int(increment) |
dd0ea6474ea0
fixes to crashing PTO trailer when empty, and numbering
andy
parents:
2693
diff
changeset
|
1019 |
output = self._seq.thisf(id) |
dd0ea6474ea0
fixes to crashing PTO trailer when empty, and numbering
andy
parents:
2693
diff
changeset
|
1020 |
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
|
1021 |
self.handle_data(output) |
1683 | 1022 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1023 |
def end_seq(self): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1024 |
pass |
266 | 1025 |
|
4059 | 1026 |
def start_ondraw(self,attr): |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1027 |
defn = ABag() |
3326 | 1028 |
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
|
1029 |
else: self._syntax_error('<onDraw> needs at least a name attribute') |
506 | 1030 |
|
4277 | 1031 |
defn.label = attr.get('label',None) |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1032 |
defn.kind='onDraw' |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
1033 |
self._push('ondraw',cbDefn=defn) |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1034 |
self.handle_data('') |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
1035 |
self._pop('ondraw') |
4059 | 1036 |
start_onDraw=start_ondraw |
1037 |
end_onDraw=end_ondraw=end_seq |
|
3111
86a3158c50bd
reportlab: improved support for onDraw and SimpleIndex
rgbecker
parents:
3032
diff
changeset
|
1038 |
|
3165 | 1039 |
def start_index(self,attr): |
1040 |
attr=self.getAttributes(attr,_indexAttrMap) |
|
1041 |
defn = ABag() |
|
3326 | 1042 |
if 'item' in attr: |
3187
2d5a6655556e
tableofcontents/paraparser: allow for format and offset parameters
rgbecker
parents:
3165
diff
changeset
|
1043 |
label = attr['item'] |
3165 | 1044 |
else: |
1045 |
self._syntax_error('<index> needs at least an item attribute') |
|
3326 | 1046 |
if 'name' in attr: |
3165 | 1047 |
name = attr['name'] |
1048 |
else: |
|
1049 |
name = DEFAULT_INDEX_NAME |
|
3187
2d5a6655556e
tableofcontents/paraparser: allow for format and offset parameters
rgbecker
parents:
3165
diff
changeset
|
1050 |
format = attr.get('format',None) |
2d5a6655556e
tableofcontents/paraparser: allow for format and offset parameters
rgbecker
parents:
3165
diff
changeset
|
1051 |
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
|
1052 |
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
|
1053 |
offset = attr.get('offset',None) |
2d5a6655556e
tableofcontents/paraparser: allow for format and offset parameters
rgbecker
parents:
3165
diff
changeset
|
1054 |
if offset is not None: |
2d5a6655556e
tableofcontents/paraparser: allow for format and offset parameters
rgbecker
parents:
3165
diff
changeset
|
1055 |
try: |
2d5a6655556e
tableofcontents/paraparser: allow for format and offset parameters
rgbecker
parents:
3165
diff
changeset
|
1056 |
offset = int(offset) |
2d5a6655556e
tableofcontents/paraparser: allow for format and offset parameters
rgbecker
parents:
3165
diff
changeset
|
1057 |
except: |
2d5a6655556e
tableofcontents/paraparser: allow for format and offset parameters
rgbecker
parents:
3165
diff
changeset
|
1058 |
raise ValueError('index tag offset is %r not an int' % offset) |
3856 | 1059 |
defn.label = encode_label((label,format,offset)) |
3165 | 1060 |
defn.name = name |
1061 |
defn.kind='index' |
|
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
1062 |
self._push('index',cbDefn=defn) |
3165 | 1063 |
self.handle_data('') |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
1064 |
self._pop('index',) |
3165 | 1065 |
end_index=end_seq |
2663 | 1066 |
|
3826
02f216b6e38e
paraparser.py: support old behaviours eg ignore unknown tags etc etc
robin
parents:
3812
diff
changeset
|
1067 |
def start_unknown(self,attr): |
02f216b6e38e
paraparser.py: support old behaviours eg ignore unknown tags etc etc
robin
parents:
3812
diff
changeset
|
1068 |
pass |
02f216b6e38e
paraparser.py: support old behaviours eg ignore unknown tags etc etc
robin
parents:
3812
diff
changeset
|
1069 |
end_unknown=end_seq |
02f216b6e38e
paraparser.py: support old behaviours eg ignore unknown tags etc etc
robin
parents:
3812
diff
changeset
|
1070 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1071 |
#--------------------------------------------------------------- |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
1072 |
def _push(self,tag,**attr): |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1073 |
frag = copy.copy(self._stack[-1]) |
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
1074 |
frag.__tag__ = tag |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1075 |
_applyAttributes(frag,attr) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1076 |
self._stack.append(frag) |
96 | 1077 |
|
4097
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
1078 |
def _pop(self,tag): |
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
1079 |
frag = self._stack.pop() |
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
1080 |
if tag==frag.__tag__: return frag |
1c2ebf285cb7
paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents:
4077
diff
changeset
|
1081 |
raise ValueError('Parse error: saw </%s> instead of expected </%s>' % (tag,frag.__tag__)) |
96 | 1082 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1083 |
def getAttributes(self,attr,attrMap): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1084 |
A = {} |
3723
99aa837b6703
second stage of port to Python 3.3; working hello world
rptlab
parents:
3721
diff
changeset
|
1085 |
for k, v in attr.items(): |
1940 | 1086 |
if not self.caseSensitive: |
3731 | 1087 |
k = k.lower() |
4220
c0e82d246798
add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents:
4181
diff
changeset
|
1088 |
if k in attrMap: |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1089 |
j = attrMap[k] |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1090 |
func = j[1] |
4255
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
1091 |
A[j[0]] = v if func is None else func(v) |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1092 |
else: |
4255
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
1093 |
self._syntax_error('invalid attribute name %s attrMap=%r'% (k,list(sorted(attrMap.keys())))) |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1094 |
return A |
119 | 1095 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1096 |
#---------------------------------------------------------------- |
96 | 1097 |
|
4255
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
1098 |
def __init__(self,verbose=0, caseSensitive=0, ignoreUnknownTags=1, crashOnError=True): |
4077
ac3fcb7cc6f4
paraparser.py: fix convert_charrefs usage in HTMLParser.__init__; pointed out by Ivan Tchomgue @ bitbucket
robin
parents:
4067
diff
changeset
|
1099 |
HTMLParser.__init__(self, |
ac3fcb7cc6f4
paraparser.py: fix convert_charrefs usage in HTMLParser.__init__; pointed out by Ivan Tchomgue @ bitbucket
robin
parents:
4067
diff
changeset
|
1100 |
**(dict(convert_charrefs=False) if sys.version_info>=(3,4) else {})) |
3826
02f216b6e38e
paraparser.py: support old behaviours eg ignore unknown tags etc etc
robin
parents:
3812
diff
changeset
|
1101 |
self.verbose = verbose |
4077
ac3fcb7cc6f4
paraparser.py: fix convert_charrefs usage in HTMLParser.__init__; pointed out by Ivan Tchomgue @ bitbucket
robin
parents:
4067
diff
changeset
|
1102 |
#HTMLParser is case insenstive anyway, but the rml interface still needs this |
4059 | 1103 |
#all start/end_ methods should have a lower case version for HMTMParser |
3826
02f216b6e38e
paraparser.py: support old behaviours eg ignore unknown tags etc etc
robin
parents:
3812
diff
changeset
|
1104 |
self.caseSensitive = caseSensitive |
02f216b6e38e
paraparser.py: support old behaviours eg ignore unknown tags etc etc
robin
parents:
3812
diff
changeset
|
1105 |
self.ignoreUnknownTags = ignoreUnknownTags |
4255
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
1106 |
self._crashOnError = crashOnError |
266 | 1107 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1108 |
def _iReset(self): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1109 |
self.fragList = [] |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1110 |
if hasattr(self, 'bFragList'): delattr(self,'bFragList') |
250 | 1111 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1112 |
def _reset(self, style): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1113 |
'''reset the parser''' |
96 | 1114 |
|
3957
c7cedb1dde29
paraparser.py: remove usage of pyRXPU, remove attempted optimization of texts
robin
parents:
3956
diff
changeset
|
1115 |
HTMLParser.reset(self) |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1116 |
# 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
|
1117 |
self.errors = [] |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1118 |
self._style = style |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1119 |
self._iReset() |
96 | 1120 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1121 |
#---------------------------------------------------------------- |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1122 |
def handle_data(self,data): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1123 |
"Creates an intermediate representation of string segments." |
96 | 1124 |
|
3954
44dbe56eb858
first attempt at HTMLParser-based paraparser
Andy Robinson <andy@reportlab.com>
parents:
3937
diff
changeset
|
1125 |
#The old parser would only 'see' a string after all entities had |
44dbe56eb858
first attempt at HTMLParser-based paraparser
Andy Robinson <andy@reportlab.com>
parents:
3937
diff
changeset
|
1126 |
#been processed. Thus, 'Hello ™ World' would emerge as one |
44dbe56eb858
first attempt at HTMLParser-based paraparser
Andy Robinson <andy@reportlab.com>
parents:
3937
diff
changeset
|
1127 |
#fragment. HTMLParser processes these separately. We want to ensure |
44dbe56eb858
first attempt at HTMLParser-based paraparser
Andy Robinson <andy@reportlab.com>
parents:
3937
diff
changeset
|
1128 |
#that successive calls like this are concatenated, to prevent too many |
44dbe56eb858
first attempt at HTMLParser-based paraparser
Andy Robinson <andy@reportlab.com>
parents:
3937
diff
changeset
|
1129 |
#fragments being created. |
44dbe56eb858
first attempt at HTMLParser-based paraparser
Andy Robinson <andy@reportlab.com>
parents:
3937
diff
changeset
|
1130 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1131 |
frag = copy.copy(self._stack[-1]) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1132 |
if hasattr(frag,'cbDefn'): |
2857
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
1133 |
kind = frag.cbDefn.kind |
487dc2450eec
reprotlab: inline images horizontal positioning OK
rgbecker
parents:
2836
diff
changeset
|
1134 |
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
|
1135 |
elif hasattr(frag,'_selfClosingTag'): |
2663 | 1136 |
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
|
1137 |
return |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1138 |
else: |
4249
8fc7d11bdee0
add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents:
4220
diff
changeset
|
1139 |
# if sub and sup are both on they will cancel each other out |
8fc7d11bdee0
add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents:
4220
diff
changeset
|
1140 |
if frag.sub == 1 and frag.sup == 1: |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1141 |
frag.sub = 0 |
4249
8fc7d11bdee0
add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents:
4220
diff
changeset
|
1142 |
frag.sup = 0 |
96 | 1143 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1144 |
if frag.sub: |
4255
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
1145 |
frag.rise = -fontSizeNormalize(frag,'supr',frag.fontSize*subFraction) |
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
1146 |
frag.fontSize = fontSizeNormalize(frag,'sups',frag.fontSize-min(sizeDelta,0.2*frag.fontSize)) |
4249
8fc7d11bdee0
add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents:
4220
diff
changeset
|
1147 |
elif frag.sup: |
4255
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
1148 |
frag.rise = fontSizeNormalize(frag,'supr',frag.fontSize*supFraction) |
89ea1d46b4a0
make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents:
4252
diff
changeset
|
1149 |
frag.fontSize = fontSizeNormalize(frag,'sups',frag.fontSize-min(sizeDelta,0.2*frag.fontSize)) |
112 | 1150 |
|
2584
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
1151 |
if frag.greek: |
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
1152 |
frag.fontName = 'symbol' |
0fed2bd8ef90
reportlab: fixed <greek> added <unichar [name=..|code=../> to paragraph
rgbecker
parents:
2575
diff
changeset
|
1153 |
data = _greekConvert(data) |
514
3784fe357a72
Slight optimisation in handle_data for cbdefn frags
rgbecker
parents:
508
diff
changeset
|
1154 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1155 |
# bold, italic, and underline |
2861 | 1156 |
frag.fontName = tt2ps(frag.fontName,frag.bold,frag.italic) |
96 | 1157 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1158 |
#save our data |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1159 |
frag.text = data |
514
3784fe357a72
Slight optimisation in handle_data for cbdefn frags
rgbecker
parents:
508
diff
changeset
|
1160 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1161 |
if hasattr(frag,'isBullet'): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1162 |
delattr(frag,'isBullet') |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1163 |
self.bFragList.append(frag) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1164 |
else: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1165 |
self.fragList.append(frag) |
96 | 1166 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1167 |
def handle_cdata(self,data): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1168 |
self.handle_data(data) |
211 | 1169 |
|
2376 | 1170 |
def _setup_for_parse(self,style): |
1171 |
self._seq = reportlab.lib.sequencer.getSequencer() |
|
1172 |
self._reset(style) # reinitialise the parser |
|
1173 |
||
1174 |
def _complete_parse(self): |
|
3954
44dbe56eb858
first attempt at HTMLParser-based paraparser
Andy Robinson <andy@reportlab.com>
parents:
3937
diff
changeset
|
1175 |
"Reset after parsing, to be ready for next paragraph" |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1176 |
del self._seq |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1177 |
style = self._style |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1178 |
del self._style |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1179 |
if len(self.errors)==0: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1180 |
fragList = self.fragList |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1181 |
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
|
1182 |
self._iReset() |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1183 |
else: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1160
diff
changeset
|
1184 |
fragList = bFragList = None |
2575 | 1185 |
|
1677 |