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