[Zope-Checkins] CVS: Zope2 - ClassicDocumentClass.py:1.12 DocumentClass.py:1.17 HTMLClass.py:1.9 STletters.py:1.2 MML.py:NONE
andreas@serenade.digicool.com
andreas@serenade.digicool.com
Thu, 3 May 2001 12:27:03 -0400
Update of /cvs-repository/Zope2/lib/python/StructuredText
In directory serenade.digicool.com:/tmp/cvs-serv18482
Modified Files:
ClassicDocumentClass.py DocumentClass.py HTMLClass.py
STletters.py
Removed Files:
MML.py
Log Message:
cleaner handling of punctuation, several fixes, enhanced
locale support
--- Updated File ClassicDocumentClass.py in package Zope2 --
--- ClassicDocumentClass.py 2001/05/01 20:01:55 1.11
+++ ClassicDocumentClass.py 2001/05/03 16:27:02 1.12
@@ -85,7 +85,7 @@
import re, ST, STDOM
from string import split, join, replace, expandtabs, strip, find
-from STletters import letters
+from STletters import letters,lettpunc,punctuations
StringType=type('')
ListType=type([])
@@ -584,7 +584,7 @@
def doc_emphasize(
self, s,
- expr = re.compile('\s*\*([ \n%s0-9.:/;,\'\"\?\=\-\>\<\(\)]+)\*(?!\*|-)' % letters).search
+ expr = re.compile('\s*\*([ \n%s0-9]+)\*(?!\*|-)' % lettpunc).search
):
r=expr(s)
@@ -632,7 +632,7 @@
def doc_underline(self,
s,
- expr=re.compile("\s+\_([%s0-9\s\.,\?\/]+)\_" % letters).search):
+ expr=re.compile("\s+\_([0-9%s ]+)\_" % lettpunc).search):
result = expr(s)
if result:
@@ -644,7 +644,7 @@
def doc_strong(self,
s,
- expr = re.compile('\s*\*\*([ \n%s0-9.:/;\-,!\?\'\"]+)\*\*' % letters).search
+ expr = re.compile('\s*\*\*([ \n%s0-9]+)\*\*' % lettpunc).search
):
r=expr(s)
@@ -657,19 +657,9 @@
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):
+ 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):
- #expr1=re.compile('\"([ a-zA-Z0-9.:/;,\n\~\(\)\-]+)\"'
- # ':'
- # '([a-zA-Z0-9.:/;,\n\~]+)(?=(\s+|\.|\!|\?))'
- # ).search,
- #expr2=re.compile('\"([ a-zA-Z0-9./:]+)\"'
- # ',\s+'
- # '([ a-zA-Z0-9@.:/;]+)(?=(\s+|\.|\!|\?))'
- # ).search,
-
- punctuation = re.compile("[\,\.\?\!\;]+").match
r=expr1(s) or expr2(s)
if r:
@@ -679,19 +669,16 @@
start,e = r.span(1)
name = s[start:e]
name = replace(name,'"','',2)
- #start = start + 1
st,end = r.span(3)
- if punctuation(s[end-1:end]):
- end = end -1
- link = s[st:end]
- #end = end - 1
+ if s[end-1:end] in punctuations: end-=1
+ link = s[st:end]
+
# 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
--- Updated File DocumentClass.py in package Zope2 --
--- DocumentClass.py 2001/05/01 20:01:55 1.16
+++ DocumentClass.py 2001/05/03 16:27:02 1.17
@@ -85,7 +85,7 @@
import re, ST, STDOM
from string import split, join, replace, expandtabs, strip, find, rstrip
-from STletters import letters
+from STletters import *
StringType=type('')
@@ -867,7 +867,7 @@
def doc_emphasize(
self, s,
- expr = re.compile(r'\s*\*([ \n%s0-9.:/;,\'\"\?\-\_\/\=\-\>\<\(\)]+)\*(?!\*|-)' % letters).search
+ expr = re.compile(r'\s*\*([ \n%s0-9]+)\*(?!\*|-)' % lettpunc).search
):
r=expr(s)
@@ -914,7 +914,7 @@
def doc_underline(self,
s,
- expr=re.compile(r"\s+\_([%s0-9\s\.,\?]+)\_" % letters).search):
+ expr=re.compile(r"\s+\_([%s0-9\s]+)\_" % lettpunc).search):
result = expr(s)
if result:
@@ -926,7 +926,7 @@
def doc_strong(self,
s,
- expr = re.compile(r'\s*\*\*([ \n%sZ0-9.:/;\-,!\?\'\"]+)\*\*' % letters).search
+ expr = re.compile(r'\s*\*\*([ \n%s0-9]+)\*\*' % lettpunc).search
):
r=expr(s)
--- Updated File HTMLClass.py in package Zope2 --
--- HTMLClass.py 2001/05/02 16:45:55 1.8
+++ HTMLClass.py 2001/05/03 16:27:02 1.9
@@ -215,7 +215,7 @@
else:
getattr(self, self.element_types[c.getNodeName()])(
c, level, output)
- output('</p>')
+ output('</p>\n')
def link(self, doc, level, output):
output('<a href="%s">' % doc.href)
--- Updated File STletters.py in package Zope2 --
--- STletters.py 2001/04/27 18:21:59 1.1
+++ STletters.py 2001/05/03 16:27:02 1.2
@@ -7,8 +7,9 @@
except:
pass
-
import string
-letters = string.letters
+letters = string.letters
+punctuations = string.punctuation
+lettpunc = letters + punctuations
--- Removed file MML.py from package Zope2 --