author | andy_robinson |
Sat, 20 May 2000 15:36:42 +0000 | |
changeset 238 | 4c6d5db33635 |
parent 218 | 274db2129c04 |
child 248 | c103b7a55e79 |
permissions | -rw-r--r-- |
162 | 1 |
#!/bin/env python |
2 |
############################################################################### |
|
3 |
# |
|
4 |
# ReportLab Public License Version 1.0 |
|
5 |
# |
|
6 |
# Except for the change of names the spirit and intention of this |
|
7 |
# license is the same as that of Python |
|
8 |
# |
|
9 |
# (C) Copyright ReportLab Inc. 1998-2000. |
|
10 |
# |
|
11 |
# |
|
12 |
# All Rights Reserved |
|
13 |
# |
|
14 |
# Permission to use, copy, modify, and distribute this software and its |
|
15 |
# documentation for any purpose and without fee is hereby granted, provided |
|
16 |
# that the above copyright notice appear in all copies and that both that |
|
17 |
# copyright notice and this permission notice appear in supporting |
|
18 |
# documentation, and that the name of ReportLab not be used |
|
19 |
# in advertising or publicity pertaining to distribution of the software |
|
20 |
# without specific, written prior permission. |
|
21 |
# |
|
22 |
# |
|
23 |
# Disclaimer |
|
24 |
# |
|
25 |
# ReportLab Inc. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS |
|
26 |
# SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, |
|
27 |
# IN NO EVENT SHALL ReportLab BE LIABLE FOR ANY SPECIAL, INDIRECT |
|
28 |
# OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS |
|
29 |
# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR |
|
30 |
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
|
31 |
# PERFORMANCE OF THIS SOFTWARE. |
|
32 |
# |
|
33 |
############################################################################### |
|
34 |
# $Log: paraparser.py,v $ |
|
238 | 35 |
# Revision 1.18 2000/05/20 15:36:42 andy_robinson |
36 |
# Removed 1.5.2-style getattr call |
|
37 |
# |
|
218
274db2129c04
Fixes/Changes to get testplatypus to work with new framework
rgbecker
parents:
211
diff
changeset
|
38 |
# Revision 1.17 2000/05/16 14:28:55 rgbecker |
274db2129c04
Fixes/Changes to get testplatypus to work with new framework
rgbecker
parents:
211
diff
changeset
|
39 |
# Fixes/Changes to get testplatypus to work with new framework |
238 | 40 |
# |
211 | 41 |
# Revision 1.16 2000/05/15 12:15:29 rgbecker |
42 |
# CDATA handler added |
|
218
274db2129c04
Fixes/Changes to get testplatypus to work with new framework
rgbecker
parents:
211
diff
changeset
|
43 |
# |
209 | 44 |
# Revision 1.15 2000/05/13 16:04:06 rgbecker |
45 |
# made size alias of fontsize for <para> |
|
211 | 46 |
# |
192 | 47 |
# Revision 1.14 2000/05/11 14:05:17 rgbecker |
48 |
# Use reportlab.lib.xmllib |
|
209 | 49 |
# |
162 | 50 |
# Revision 1.13 2000/04/25 13:07:57 rgbecker |
51 |
# Added license |
|
192 | 52 |
# |
238 | 53 |
__version__=''' $Id: paraparser.py,v 1.18 2000/05/20 15:36:42 andy_robinson Exp $ ''' |
96 | 54 |
import string |
119 | 55 |
import re |
56 |
from types import TupleType |
|
96 | 57 |
import sys |
58 |
import os |
|
59 |
import copy |
|
60 |
||
192 | 61 |
#try: |
62 |
# from xml.parsers import xmllib |
|
63 |
# _xmllib_newStyle = 1 |
|
209 | 64 |
try: |
65 |
from reportlab.lib import xmllib |
|
66 |
_xmllib_newStyle = 1 |
|
67 |
except ImportError: |
|
68 |
import xmllib |
|
69 |
_xmllib_newStyle = 0 |
|
70 |
||
96 | 71 |
|
72 |
from reportlab.lib.colors import stringToColor, white, black, red, Color |
|
73 |
from reportlab.lib.fonts import tt2ps, ps2tt |
|
119 | 74 |
from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY |
75 |
||
76 |
_re_para = re.compile('^\\s*<\\s*para(\\s+|>)') |
|
96 | 77 |
|
78 |
sizeDelta = 2 # amount to reduce font size by for super and sub script |
|
79 |
subFraction = 0.5 # fraction of font size that a sub script should be lowered |
|
80 |
superFraction = 0.5 # fraction of font size that a super script should be raised |
|
81 |
||
102 | 82 |
def _num(s): |
119 | 83 |
if s[0] in ['+','-']: |
84 |
try: |
|
85 |
return ('relative',int(s)) |
|
86 |
except ValueError: |
|
87 |
return ('relative',float(s)) |
|
88 |
else: |
|
89 |
try: |
|
90 |
return int(s) |
|
91 |
except ValueError: |
|
92 |
return float(s) |
|
93 |
||
94 |
def _align(s): |
|
95 |
s = string.lower(s) |
|
96 |
if s=='left': return TA_LEFT |
|
97 |
elif s=='right': return TA_RIGHT |
|
98 |
elif s=='justify': return TA_JUSTIFY |
|
99 |
elif s in ('centre','center'): return TA_CENTER |
|
100 |
else: raise ValueError |
|
101 |
||
102 |
_paraAttrMap = {'font': ('fontName', None), |
|
103 |
'fontsize': ('fontSize', _num), |
|
209 | 104 |
'size': ('fontSize', _num), |
119 | 105 |
'leading': ('leading', _num), |
106 |
'lindent': ('leftIndent', _num), |
|
107 |
'rindent': ('rightIndent', _num), |
|
108 |
'findent': ('firstLineIndent', _num), |
|
109 |
'align': ('alignment', _align), |
|
110 |
'spaceb': ('spaceBefore', _num), |
|
111 |
'spacea': ('spaceAfter', _num), |
|
112 |
'bfont': ('bulletFontName', None), |
|
113 |
'bfontsize': ('bulletFontIndent',_num), |
|
114 |
'bindent': ('bulletFontIndent',_num), |
|
218
274db2129c04
Fixes/Changes to get testplatypus to work with new framework
rgbecker
parents:
211
diff
changeset
|
115 |
'bcolor': ('bulletColor',stringToColor), |
119 | 116 |
'color':('textColor',stringToColor), |
117 |
'fg': ('textColor',stringToColor)} |
|
118 |
||
119 |
#things which are valid font attributes |
|
120 |
_fontAttrMap = {'size': ('fontSize', _num), |
|
121 |
'name': ('fontName', None), |
|
122 |
'fg': ('textColor', stringToColor), |
|
123 |
'color':('textColor', stringToColor)} |
|
124 |
||
125 |
def _addAttributeNames(m): |
|
126 |
K = m.keys() |
|
127 |
for k in K: |
|
128 |
n = string.lower(m[k][0]) |
|
129 |
if not m.has_key(n): |
|
130 |
m[n] = m[k] |
|
131 |
||
132 |
_addAttributeNames(_paraAttrMap) |
|
133 |
_addAttributeNames(_fontAttrMap) |
|
134 |
||
135 |
def _applyAttributes(obj, attr): |
|
136 |
for k, v in attr.items(): |
|
137 |
if type(v) is TupleType and v[0]=='relative': |
|
238 | 138 |
#AR 20/5/2000 - remove 1.5.2-ism |
139 |
#v = v[1]+getattr(obj,k,0) |
|
140 |
if hasattr(obj, k): |
|
141 |
v = v[1]+getattr(obj,k) |
|
142 |
else: |
|
143 |
v = v[1] |
|
119 | 144 |
setattr(obj,k,v) |
102 | 145 |
|
96 | 146 |
#characters not supported: epsi, Gammad, gammad, kappav, rhov, Upsi, upsi |
147 |
greeks = { |
|
148 |
'alpha':'a', |
|
149 |
'beta':'b', |
|
150 |
'chi':'c', |
|
151 |
'Delta':'D', |
|
152 |
'delta':'d', |
|
153 |
'epsiv':'e', |
|
154 |
'eta':'h', |
|
155 |
'Gamma':'G', |
|
156 |
'gamma':'g', |
|
157 |
'iota':'i', |
|
158 |
'kappa':'k', |
|
159 |
'Lambda':'L', |
|
160 |
'lambda':'l', |
|
161 |
'mu':'m', |
|
162 |
'nu':'n', |
|
163 |
'Omega':'W', |
|
164 |
'omega':'w', |
|
165 |
'omicron':'x', |
|
166 |
'Phi':'F', |
|
167 |
'phi':'f', |
|
168 |
'phiv':'j', |
|
169 |
'Pi':'P', |
|
170 |
'pi':'p', |
|
171 |
'piv':'v', |
|
172 |
'Psi':'Y', |
|
173 |
'psi':'y', |
|
174 |
'rho':'r', |
|
175 |
'Sigma':'S', |
|
176 |
'sigma':'s', |
|
177 |
'sigmav':'V', |
|
178 |
'tau':'t', |
|
179 |
'Theta':'Q', |
|
180 |
'theta':'q', |
|
181 |
'thetav':'j', |
|
182 |
'Xi':'X', |
|
183 |
'xi':'x', |
|
184 |
'zeta':'z' |
|
185 |
} |
|
186 |
||
187 |
#------------------------------------------------------------------------ |
|
188 |
class ParaFrag: |
|
189 |
"""class ParaFrag contains the intermediate representation of string |
|
190 |
segments as they are being parsed by the XMLParser. |
|
191 |
""" |
|
102 | 192 |
def __init__(self,**attr): |
193 |
for k,v in attr.items(): |
|
194 |
setattr(self,k,v) |
|
195 |
||
196 |
def clone(self,**attr): |
|
197 |
n = apply(ParaFrag,(),self.__dict__) |
|
198 |
if attr != {}: apply(ParaFrag.__init__,(n,),attr) |
|
199 |
return n |
|
96 | 200 |
|
201 |
#------------------------------------------------------------------ |
|
202 |
# The ParaFormatter will be able to format the following xml |
|
203 |
# tags: |
|
204 |
# < b > < /b > - bold |
|
205 |
# < i > < /i > - italics |
|
206 |
# < u > < /u > - underline |
|
207 |
# < super > < /super > - superscript |
|
208 |
# < sub > < /sub > - subscript |
|
209 |
# <font name=fontfamily/fontname color=colorname size=float> |
|
210 |
# |
|
119 | 211 |
# The whole may be surrounded by <para> </para> tags |
212 |
# |
|
96 | 213 |
# It will also be able to handle any MathML specified Greek characters. |
214 |
#------------------------------------------------------------------ |
|
215 |
class ParaParser(xmllib.XMLParser): |
|
216 |
||
217 |
#---------------------------------------------------------- |
|
218 |
# First we will define all of the xml tag handler functions. |
|
219 |
# |
|
220 |
# start_<tag>(attributes) |
|
221 |
# end_<tag>() |
|
222 |
# |
|
223 |
# While parsing the xml ParaFormatter will call these |
|
224 |
# functions to handle the string formatting tags. |
|
225 |
# At the start of each tag the corresponding field will |
|
226 |
# be set to 1 and at the end tag the corresponding field will |
|
227 |
# be set to 0. Then when handle_data is called the options |
|
228 |
# for that data will be aparent by the current settings. |
|
229 |
#---------------------------------------------------------- |
|
230 |
||
231 |
#### bold |
|
232 |
def start_b( self, attributes ): |
|
233 |
self._push(bold=1) |
|
234 |
||
235 |
def end_b( self ): |
|
236 |
self._pop(bold=1) |
|
237 |
||
238 |
#### italics |
|
239 |
def start_i( self, attributes ): |
|
240 |
self._push(italic=1) |
|
241 |
||
242 |
def end_i( self ): |
|
243 |
self._pop(italic=1) |
|
244 |
||
245 |
#### underline |
|
246 |
def start_u( self, attributes ): |
|
247 |
self._push(underline=1) |
|
248 |
||
249 |
def end_u( self ): |
|
250 |
self._pop(underline=1) |
|
251 |
||
252 |
#### super script |
|
253 |
def start_super( self, attributes ): |
|
254 |
self._push(super=1) |
|
255 |
||
256 |
def end_super( self ): |
|
257 |
self._pop(super=1) |
|
258 |
||
259 |
#### sub script |
|
260 |
def start_sub( self, attributes ): |
|
261 |
self._push(sub=1) |
|
262 |
||
263 |
def end_sub( self ): |
|
264 |
self._pop(sub=1) |
|
265 |
||
266 |
#### greek script |
|
267 |
if _xmllib_newStyle: |
|
268 |
def handle_entityref(self,name): |
|
269 |
if greeks.has_key(name): |
|
270 |
self._push(greek=1) |
|
271 |
self.handle_data(greeks[name]) |
|
272 |
self._pop(greek=1) |
|
273 |
else: |
|
274 |
xmllib.XMLParser.handle_entityref(self,name) |
|
134 | 275 |
|
276 |
def syntax_error(self,lineno,message): |
|
277 |
self._syntax_error(message) |
|
278 |
||
96 | 279 |
else: |
280 |
def start_greekLetter(self, attributes,letter): |
|
281 |
self._push(greek=1) |
|
282 |
self.handle_data(letter) |
|
283 |
||
134 | 284 |
def syntax_error(self,message): |
285 |
self._syntax_error(message) |
|
286 |
||
287 |
def _syntax_error(self,message): |
|
288 |
if message[:10]=="attribute " and message[-17:]==" value not quoted": return |
|
289 |
self.errors.append(message) |
|
290 |
||
96 | 291 |
def start_greek(self, attributes): |
292 |
self._push(greek=1) |
|
293 |
||
294 |
def end_greek(self): |
|
295 |
self._pop(greek=1) |
|
296 |
||
119 | 297 |
|
96 | 298 |
def start_font(self,attr): |
119 | 299 |
A = self.getAttributes(attr,_fontAttrMap) |
113 | 300 |
apply(self._push,(),A) |
96 | 301 |
|
302 |
def end_font(self): |
|
303 |
self._pop() |
|
304 |
||
119 | 305 |
def start_para(self,attr): |
306 |
style = self._style |
|
307 |
if attr!={}: |
|
308 |
style = copy.deepcopy(style) |
|
309 |
_applyAttributes(style,self.getAttributes(attr,_paraAttrMap)) |
|
310 |
self._style = style |
|
311 |
||
312 |
# initialize semantic values |
|
313 |
frag = ParaFrag() |
|
314 |
frag.sub = 0 |
|
315 |
frag.super = 0 |
|
316 |
frag.rise = 0 |
|
317 |
frag.fontName, frag.bold, frag.italic = ps2tt(style.fontName) |
|
318 |
frag.fontSize = style.fontSize |
|
319 |
frag.underline = 0 |
|
320 |
frag.textColor = style.textColor |
|
321 |
frag.greek = 0 |
|
322 |
self._stack = [frag] |
|
323 |
||
324 |
def end_para(self): |
|
325 |
self._pop() |
|
326 |
||
327 |
def _push(self,**attr): |
|
96 | 328 |
frag = copy.copy(self._stack[-1]) |
119 | 329 |
_applyAttributes(frag,attr) |
96 | 330 |
self._stack.append(frag) |
331 |
||
332 |
def _pop(self,**kw): |
|
333 |
frag = self._stack[-1] |
|
334 |
del self._stack[-1] |
|
335 |
for k, v in kw.items(): |
|
336 |
assert getattr(frag,k)==v |
|
337 |
return frag |
|
338 |
||
119 | 339 |
def getAttributes(self,attr,attrMap): |
340 |
A = {} |
|
341 |
for k, v in attr.items(): |
|
342 |
k = string.lower(k) |
|
343 |
if k in attrMap.keys(): |
|
344 |
j = attrMap[k] |
|
345 |
func = j[1] |
|
346 |
try: |
|
123 | 347 |
A[j[0]] = (func is None) and v or apply(func,(v,)) |
119 | 348 |
except: |
134 | 349 |
self._syntax_error('%s: invalid value %s'%(k,v)) |
119 | 350 |
else: |
134 | 351 |
self._syntax_error('invalid attribute name %s'%k) |
119 | 352 |
return A |
353 |
||
96 | 354 |
#---------------------------------------------------------------- |
355 |
||
356 |
def __init__(self,verbose=0): |
|
357 |
if _xmllib_newStyle: |
|
358 |
xmllib.XMLParser.__init__(self,verbose=verbose) |
|
359 |
else: |
|
360 |
xmllib.XMLParser.__init__(self) |
|
361 |
# set up handlers for various tags |
|
362 |
self.elements = { 'b': (self.start_b, self.end_b), |
|
363 |
'u': (self.start_u, self.end_u), |
|
364 |
'i': (self.start_i, self.end_i), |
|
365 |
'super': (self.start_super, self.end_super), |
|
366 |
'sub': (self.start_sub, self.end_sub), |
|
367 |
'font': (self.start_font, self.end_font), |
|
132 | 368 |
'greek': (self.start_greek, self.end_greek), |
369 |
'para': (self.start_para, self.end_para) |
|
96 | 370 |
} |
371 |
||
132 | 372 |
|
96 | 373 |
# automatically add handlers for all of the greek characters |
374 |
for item in greeks.keys(): |
|
375 |
self.elements[item] = (lambda attr,self=self,letter=greeks[item]: |
|
376 |
self.start_greekLetter(attr,letter), self.end_greek) |
|
377 |
||
378 |
# set up dictionary for greek characters, this is a class variable |
|
192 | 379 |
self.entitydefs = self.entitydefs.copy() |
96 | 380 |
for item in greeks.keys(): |
381 |
self.entitydefs[item] = '<%s/>' % item |
|
382 |
||
383 |
def _reset(self, style): |
|
384 |
'''reset the parser''' |
|
385 |
xmllib.XMLParser.reset(self) |
|
386 |
||
387 |
# initialize list of string segments to empty |
|
388 |
self.errors = [] |
|
389 |
self.fragList = [] |
|
119 | 390 |
self._style = style |
96 | 391 |
|
392 |
#---------------------------------------------------------------- |
|
393 |
def handle_data(self,data): |
|
394 |
"Creates an intermediate representation of string segments." |
|
395 |
||
396 |
frag = copy.copy(self._stack[-1]) |
|
102 | 397 |
#save our data |
398 |
frag.text = data |
|
96 | 399 |
|
400 |
# if sub and super are both one they will cancel each other out |
|
401 |
if frag.sub == 1 and frag.super == 1: |
|
402 |
frag.sub = 0 |
|
403 |
frag.super = 0 |
|
404 |
||
112 | 405 |
if frag.sub: |
406 |
frag.rise = -frag.fontSize*subFraction |
|
407 |
frag.fontSize = max(frag.fontSize-sizeDelta,3) |
|
115 | 408 |
elif frag.super: |
112 | 409 |
frag.rise = frag.fontSize*superFraction |
115 | 410 |
frag.fontSize = max(frag.fontSize-sizeDelta,3) |
112 | 411 |
|
102 | 412 |
if frag.greek: frag.fontName = 'symbol' |
96 | 413 |
# bold, italic, and underline |
102 | 414 |
frag.fontName = tt2ps(frag.fontName,frag.bold,frag.italic) |
96 | 415 |
|
416 |
self.fragList.append(frag) |
|
417 |
||
211 | 418 |
def handle_cdata(self,data): |
419 |
self.handle_data(data) |
|
420 |
||
96 | 421 |
#---------------------------------------------------------------- |
102 | 422 |
def parse(self, text, style): |
96 | 423 |
"""Given a formatted string will return a list of |
424 |
ParaFrag objects with their calculated widths. |
|
425 |
If errors occur None will be returned and the |
|
426 |
self.errors holds a list of the error messages. |
|
427 |
""" |
|
428 |
||
429 |
# the xmlparser requires that all text be surrounded by xml |
|
430 |
# tags, therefore we must throw some unused flags around the |
|
431 |
# given string |
|
432 |
self._reset(style) # reinitialise the parser |
|
119 | 433 |
if not(len(text)>=6 and text[0]=='<' and _re_para.match(text)): |
434 |
text = "<para>"+text+"</para>" |
|
435 |
self.feed(text) |
|
96 | 436 |
self.close() # force parsing to complete |
119 | 437 |
style = self._style |
438 |
del self._style |
|
96 | 439 |
if len(self.errors)==0: |
440 |
fragList = self.fragList |
|
441 |
self.fragList = [] |
|
119 | 442 |
return style, fragList |
96 | 443 |
else: |
119 | 444 |
return style, None |
96 | 445 |
|
446 |
if __name__=='__main__': |
|
129 | 447 |
from reportlab.platypus.paragraph import cleanBlockQuotedText |
96 | 448 |
_parser=ParaParser() |
133 | 449 |
def check_text(text,p=_parser): |
450 |
print '##########' |
|
451 |
text = cleanBlockQuotedText(text) |
|
452 |
l,rv = p.parse(text,style) |
|
453 |
if rv is None: |
|
454 |
for l in _parser.errors: |
|
455 |
print l |
|
456 |
else: |
|
457 |
print 'ParaStyle', l.fontName,l.fontSize,l.textColor |
|
458 |
for l in rv: |
|
459 |
print l.fontName,l.fontSize,l.textColor,l.bold, l.rise, l.text[:25] |
|
96 | 460 |
|
461 |
style=ParaFrag() |
|
462 |
style.fontName='Times-Roman' |
|
463 |
style.fontSize = 12 |
|
464 |
style.textColor = black |
|
465 |
||
466 |
text=''' |
|
467 |
<b><i><greek>a</greek>D</i></b>β |
|
468 |
<font name="helvetica" size="15" color=green> |
|
469 |
Tell me, O muse, of that ingenious hero who travelled far and wide |
|
113 | 470 |
after</font> he had sacked the famous town of Troy. Many cities did he visit, |
96 | 471 |
and many were the nations with whose manners and customs he was acquainted; |
472 |
moreover he suffered much by sea while trying to save his own life |
|
473 |
and bring his men safely home; but do what he might he could not save |
|
474 |
his men, for they perished through their own sheer folly in eating |
|
475 |
the cattle of the Sun-god Hyperion; so the god prevented them from |
|
476 |
ever reaching home. Tell me, too, about all these things, O daughter |
|
115 | 477 |
of Jove, from whatsoever source you<super>1</super> may know them. |
96 | 478 |
''' |
133 | 479 |
check_text(text) |
480 |
check_text('<para> </para>') |
|
209 | 481 |
check_text('<para font="times-bold" size=24 leading=28.8 spaceAfter=72>ReportLab -- Reporting for the Internet Age</para>') |
133 | 482 |
check_text(''' |
483 |
<font color=red>τ</font>Tell me, O muse, of that ingenious hero who travelled far and wide |
|
484 |
after he had sacked the famous town of Troy. Many cities did he visit, |
|
485 |
and many were the nations with whose manners and customs he was acquainted; |
|
486 |
moreover he suffered much by sea while trying to save his own life |
|
487 |
and bring his men safely home; but do what he might he could not save |
|
488 |
his men, for they perished through their own sheer folly in eating |
|
489 |
the cattle of the Sun-god Hyperion; so the god prevented them from |
|
490 |
ever reaching home. Tell me, too, about all these things, O daughter |
|
491 |
of Jove, from whatsoever source you may know them.''') |
|
492 |
check_text(''' |
|
493 |
Telemachus took this speech as of good omen and rose at once, for |
|
494 |
he was bursting with what he had to say. He stood in the middle of |
|
495 |
the assembly and the good herald Pisenor brought him his staff. Then, |
|
496 |
turning to Aegyptius, "Sir," said he, "it is I, as you will shortly |
|
497 |
learn, who have convened you, for it is I who am the most aggrieved. |
|
498 |
I have not got wind of any host approaching about which I would warn |
|
499 |
you, nor is there any matter of public moment on which I would speak. |
|
500 |
My grieveance is purely personal, and turns on two great misfortunes |
|
501 |
which have fallen upon my house. The first of these is the loss of |
|
502 |
my excellent father, who was chief among all you here present, and |
|
503 |
was like a father to every one of you; the second is much more serious, |
|
504 |
and ere long will be the utter ruin of my estate. The sons of all |
|
505 |
the chief men among you are pestering my mother to marry them against |
|
506 |
her will. They are afraid to go to her father Icarius, asking him |
|
507 |
to choose the one he likes best, and to provide marriage gifts for |
|
508 |
his daughter, but day by day they keep hanging about my father's house, |
|
509 |
sacrificing our oxen, sheep, and fat goats for their banquets, and |
|
510 |
never giving so much as a thought to the quantity of wine they drink. |
|
511 |
No estate can stand such recklessness; we have now no Ulysses to ward |
|
512 |
off harm from our doors, and I cannot hold my own against them. I |
|
513 |
shall never all my days be as good a man as he was, still I would |
|
514 |
indeed defend myself if I had power to do so, for I cannot stand such |
|
515 |
treatment any longer; my house is being disgraced and ruined. Have |
|
516 |
respect, therefore, to your own consciences and to public opinion. |
|
517 |
Fear, too, the wrath of heaven, lest the gods should be displeased |
|
518 |
and turn upon you. I pray you by Jove and Themis, who is the beginning |
|
519 |
and the end of councils, [do not] hold back, my friends, and leave |
|
520 |
me singlehanded- unless it be that my brave father Ulysses did some |
|
521 |
wrong to the Achaeans which you would now avenge on me, by aiding |
|
522 |
and abetting these suitors. Moreover, if I am to be eaten out of house |
|
523 |
and home at all, I had rather you did the eating yourselves, for I |
|
524 |
could then take action against you to some purpose, and serve you |
|
525 |
with notices from house to house till I got paid in full, whereas |
|
526 |
now I have no remedy."''') |
|
527 |
||
528 |
check_text(''' |
|
529 |
But as the sun was rising from the fair sea into the firmament of |
|
530 |
heaven to shed light on mortals and immortals, they reached Pylos |
|
531 |
the city of Neleus. Now the people of Pylos were gathered on the sea |
|
532 |
shore to offer sacrifice of black bulls to Neptune lord of the Earthquake. |
|
533 |
There were nine guilds with five hundred men in each, and there were |
|
534 |
nine bulls to each guild. As they were eating the inward meats and |
|
535 |
burning the thigh bones [on the embers] in the name of Neptune, Telemachus |
|
536 |
and his crew arrived, furled their sails, brought their ship to anchor, |
|
537 |
and went ashore. ''') |
|
538 |
check_text(''' |
|
539 |
So the neighbours and kinsmen of Menelaus were feasting and making |
|
540 |
merry in his house. There was a bard also to sing to them and play |
|
541 |
his lyre, while two tumblers went about performing in the midst of |
|
542 |
them when the man struck up with his tune.]''') |
|
543 |
check_text(''' |
|
544 |
"When we had passed the [Wandering] rocks, with Scylla and terrible |
|
545 |
Charybdis, we reached the noble island of the sun-god, where were |
|
546 |
the goodly cattle and sheep belonging to the sun Hyperion. While still |
|
547 |
at sea in my ship I could bear the cattle lowing as they came home |
|
548 |
to the yards, and the sheep bleating. Then I remembered what the blind |
|
549 |
Theban prophet Teiresias had told me, and how carefully Aeaean Circe |
|
550 |
had warned me to shun the island of the blessed sun-god. So being |
|
551 |
much troubled I said to the men, 'My men, I know you are hard pressed, |
|
552 |
but listen while I tell you the prophecy that Teiresias made me, and |
|
553 |
how carefully Aeaean Circe warned me to shun the island of the blessed |
|
554 |
sun-god, for it was here, she said, that our worst danger would lie. |
|
555 |
Head the ship, therefore, away from the island.''') |
|
192 | 556 |
check_text('''< > & " '''') |
211 | 557 |
check_text('''<![CDATA[<>&'"]]>''') |