[Zope-Checkins] CVS: Zope2 - DocumentClass.py:1.26
chrism@serenade.digicool.com
chrism@serenade.digicool.com
Mon, 25 Jun 2001 22:16:40 -0400
Update of /cvs-repository/Zope2/lib/python/StructuredText
In directory serenade:/home/chrism/BackTalk/lib/python/StructuredText
Modified Files:
DocumentClass.py
Log Message:
The doc_href method is used in two cases:
"a link", http://an.aboslute.url
and
"a link":an absolute or relative URL
Fixes checked in earlier in the day to allow for only absolute URLs in the former broke regexes to do relative URLs in the latter. This is now fixed.
FWIW, why we allow the first spelling is beyond me. It has a tendency to be misinterpreted if it's not used with an absolute URL, which is why it's limited to matching absolute URLs currently.
--- Updated File DocumentClass.py in package Zope2 --
--- DocumentClass.py 2001/06/25 23:31:16 1.25
+++ DocumentClass.py 2001/06/26 02:16:40 1.26
@@ -951,12 +951,13 @@
## Some constants to make the doc_href() regex easier to read.
_DQUOTEDTEXT = r'("[ %s0-9\n\r\-\.\,\;\(\)\/\:\/\*\']+")' % letters ## double quoted text
- _URL_AND_PUNC = r'((http|https|ftp|mailto|file|about)[:/]+?[%s0-9_\@\.\,\?\!\/\:\;\-\#\~]+)' % letters
+ _ABSOLUTE_URL=r'((http|https|ftp|mailto|file|about)[:/]+?[%s0-9_\@\.\,\?\!\/\:\;\-\#\~]+)' % letters
+ _ABS_AND_RELATIVE_URL=r'([%s0-9_\@\.\,\?\!\/\:\;\-\#\~]+)' % letters
_SPACES = r'(\s*)'
def doc_href(self, s,
- expr1 = re.compile(_DQUOTEDTEXT + "(:)" + _URL_AND_PUNC + _SPACES).search,
- expr2 = re.compile(_DQUOTEDTEXT + r'(\,\s+)' + _URL_AND_PUNC + _SPACES).search):
+ expr1 = re.compile(_DQUOTEDTEXT + "(:)" + _ABS_AND_RELATIVE_URL + _SPACES).search,
+ expr2 = re.compile(_DQUOTEDTEXT + r'(\,\s+)' + _ABSOLUTE_URL + _SPACES).search):
punctuation = re.compile(r"[\,\.\?\!\;]+").match
r=expr1(s) or expr2(s)