[Zope-Checkins] CVS: Zope2 - STletters.py:1.2.10.1 ClassicDocumentClass.py:1.12.10.1
chrism@serenade.digicool.com
chrism@serenade.digicool.com
Mon, 25 Jun 2001 16:30:29 -0400
Update of /cvs-repository/Zope2/lib/python/StructuredText
In directory serenade:/home/chrism/sandboxes/Zope24Branch/lib/python/StructuredText
Modified Files:
Tag: Zope-2_4-branch
STletters.py ClassicDocumentClass.py
Log Message:
Merging from trunk.
--- Updated File STletters.py in package Zope2 --
--- STletters.py 2001/05/03 16:27:02 1.2
+++ STletters.py 2001/06/25 20:30:28 1.2.10.1
@@ -1,5 +1,4 @@
import string
-
try:
del string
import locale
@@ -9,7 +8,16 @@
import string
-letters = string.letters
-punctuations = string.punctuation
+def punc_func(exclude):
+ punc = r''
+ for char in string.punctuation:
+ if char not in exclude:
+ punc = punc + r'\%s' % char
+ return punc
-lettpunc = letters + punctuations
+digits = string.digits
+letters = string.letters
+literal_punc = punc_func("'")
+strongem_punc = punc_func('*')
+under_punc = punc_func('_')
+phrase_delimiters = r'\s\.\,\?\/\!\&\(\)'
--- Updated File ClassicDocumentClass.py in package Zope2 --
--- ClassicDocumentClass.py 2001/05/03 16:27:02 1.12
+++ ClassicDocumentClass.py 2001/06/25 20:30:28 1.12.10.1
@@ -85,7 +85,7 @@
import re, ST, STDOM
from string import split, join, replace, expandtabs, strip, find
-from STletters import letters,lettpunc,punctuations
+from STletters import letters
StringType=type('')
ListType=type([])
@@ -207,11 +207,10 @@
"""
row is a list of tuples, where each tuple is
the raw text for a cell/column and the span
- of that cell/column".
+ of that cell/column.
EX
[('this is column one',1), ('this is column two',1)]
"""
-
apply(ST.StructuredTextDocument.__init__,(self,[]),kw)
self._columns = []
for column in row:
@@ -584,7 +583,7 @@
def doc_emphasize(
self, s,
- expr = re.compile('\s*\*([ \n%s0-9]+)\*(?!\*|-)' % lettpunc).search
+ expr = re.compile('\s*\*([ \n%s0-9.:/;,\'\"\?\=\-\>\<\(\)]+)\*(?!\*|-)' % letters).search
):
r=expr(s)
@@ -632,7 +631,7 @@
def doc_underline(self,
s,
- expr=re.compile("\s+\_([0-9%s ]+)\_" % lettpunc).search):
+ expr=re.compile("\_([%s0-9\s\.,\?\/]+)\_" % letters).search):
result = expr(s)
if result:
@@ -644,7 +643,7 @@
def doc_strong(self,
s,
- expr = re.compile('\s*\*\*([ \n%s0-9]+)\*\*' % lettpunc).search
+ expr = re.compile('\s*\*\*([ \n%s0-9.:/;\-,!\?\'\"]+)\*\*' % letters).search
):
r=expr(s)
@@ -655,10 +654,11 @@
return None
def doc_href(
-
self, s,
expr1 = re.compile("(\"[ %s0-9\n\-\.\,\;\(\)\/\:\/\*\']+\")(:)([a-zA-Z0-9\@\.\,\?\!\/\:\;\-\#\~]+)([,]*\s*)" % letters).search,
- expr2 = re.compile('(\"[ %s0-9\n\-\.\:\;\(\)\/\*\']+\")([,]+\s+)([a-zA-Z0-9\@\.\,\?\!\/\:\;\-\#\~]+)(\s*)' % letters).search):
+ expr2 = re.compile('(\"[ %s0-9\n\-\.\:\;\(\)\/\*\']+\")([,]+\s+)([a-zA-Z0-9\@\.\,\?\!\/\:\;\-\#\~]+)(\s*)' % letters).search,
+ punctuation = re.compile("[\,\.\?\!\;]+").match
+ ):
r=expr1(s) or expr2(s)
@@ -669,16 +669,36 @@
start,e = r.span(1)
name = s[start:e]
name = replace(name,'"','',2)
+ #start = start + 1
st,end = r.span(3)
-
- if s[end-1:end] in punctuations: end-=1
+ if punctuation(s[end-1:end]):
+ end = end -1
link = s[st:end]
-
+ #end = end - 1
+
# name is the href title, link is the target
# of the href
return (StructuredTextLink(name, href=link),
start, end)
-
+ #return (StructuredTextLink(s[start:end], href=s[start:end]),
+ # start, end)
else:
return None
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+