Commit dcc24ff2 authored by Andreas Jung's avatar Andreas Jung

Multiple links in a paragraph with mixed link notation

(quotation+colon+URL or quotation+comma+whitespace+URL) did not
work properly (thanks to Alastair Burt for reporting and submitting
the patch).
parent 264612cd
...@@ -297,7 +297,8 @@ class DocumentClass: ...@@ -297,7 +297,8 @@ class DocumentClass:
] ]
text_types = [ text_types = [
'doc_href', 'doc_href1',
'doc_href2',
'doc_strong', 'doc_strong',
'doc_emphasize', 'doc_emphasize',
'doc_literal', 'doc_literal',
...@@ -650,16 +651,23 @@ class DocumentClass: ...@@ -650,16 +651,23 @@ class DocumentClass:
return (StructuredTextStrong(s[start:end]), start-2, end+2) return (StructuredTextStrong(s[start:end]), start-2, end+2)
else: else:
return None return None
def doc_href(
self, s,
expr1 = re.compile("(\"[ %s0-9\n\-\.\,\;\(\)\/\:\/\*\']+\")(:)([a-zA-Z0-9\@\.\,\?\!\/\:\;\-\#\~]+)([,]*\s*)" % letters).search, def doc_href1(self, s,
expr2 = re.compile('(\"[ %s0-9\n\-\.\:\;\(\)\/\*\']+\")([,]+\s+)([a-zA-Z0-9\@\.\,\?\!\/\:\;\-\#\~]+)(\s*)' % letters).search, expr=re.compile("(\"[ %s0-9\n\-\.\,\;\(\)\/\:\/\*\']+\")(:)([a-zA-Z0-9\@\.\,\?\!\/\:\;\-\#\~]+)([,]*\s*)" % letters).search
punctuation = re.compile("[\,\.\?\!\;]+").match
): ):
return self.doc_href(s, expr)
r=expr1(s) or expr2(s)
def doc_href2(self, s,
expr=re.compile('(\"[ %s0-9\n\-\.\:\;\(\)\/\*\']+\")([,]+\s+)([a-zA-Z0-9\@\.\,\?\!\/\:\;\-\#\~]+)(\s*)' % letters).search
):
return self.doc_href(s, expr)
def doc_href(self, s, expr, punctuation = re.compile("[\,\.\?\!\;]+").match):
r=expr(s)
if r: if r:
# need to grab the href part and the # need to grab the href part and the
# beginning part # beginning part
......
...@@ -368,7 +368,8 @@ class DocumentClass: ...@@ -368,7 +368,8 @@ class DocumentClass:
#'doc_underline' #'doc_underline'
text_types = [ text_types = [
'doc_sgml', 'doc_sgml',
'doc_href', 'doc_href1',
'doc_href2',
'doc_strong', 'doc_strong',
'doc_emphasize', 'doc_emphasize',
'doc_underline', 'doc_underline',
...@@ -955,13 +956,22 @@ class DocumentClass: ...@@ -955,13 +956,22 @@ class DocumentClass:
_ABS_AND_RELATIVE_URL=r'([%s0-9_\@\.\,\?\!\/\:\;\-\#\~\=\&\%%]+)' % letters _ABS_AND_RELATIVE_URL=r'([%s0-9_\@\.\,\?\!\/\:\;\-\#\~\=\&\%%]+)' % letters
_SPACES = r'(\s*)' _SPACES = r'(\s*)'
def doc_href(self, s,
expr1 = re.compile(_DQUOTEDTEXT + "(:)" + _ABS_AND_RELATIVE_URL + _SPACES).search, def doc_href1(self, s,
expr2 = re.compile(_DQUOTEDTEXT + r'(\,\s+)' + _ABSOLUTE_URL + _SPACES).search): expr=re.compile(_DQUOTEDTEXT + "(:)" + _ABS_AND_RELATIVE_URL + _SPACES).search
):
punctuation = re.compile(r"[\,\.\?\!\;]+").match return self.doc_href(s, expr)
r=expr1(s) or expr2(s)
def doc_href2(self, s,
expr=re.compile(_DQUOTEDTEXT + r'(\,\s+)' + _ABSOLUTE_URL + _SPACES).search
):
return self.doc_href(s, expr)
def doc_href(self, s, expr, punctuation=re.compile(r"[\,\.\?\!\;]+").match):
r=expr(s)
if r: if r:
# need to grab the href part and the # need to grab the href part and the
......
...@@ -14,8 +14,11 @@ ...@@ -14,8 +14,11 @@
<li><p>please click <a href="http://www.zope.org:2001/members/">here</a>" </p></li> <li><p>please click <a href="http://www.zope.org:2001/members/">here</a>" </p></li>
<li><p>please click <a href="http://www.zope.org:2001/%20/Members/zope?a=222&b=213&_xc=just%20a%20test">here</a> </p></li> <li><p>please click <a href="http://www.zope.org:2001/%20/Members/zope?a=222&b=213&_xc=just%20a%20test">here</a> </p></li>
<li><p>please click <a href="http://www.zope.org:2001/%20/Members/zope?a=222&b=213&_xc=just%20a%20test">here</a> </p></li> <li><p>please click <a href="http://www.zope.org:2001/%20/Members/zope?a=222&b=213&_xc=just%20a%20test">here</a> </p></li>
<li><p>please click <a href="http://www.zope.org:2001/%20/Members/zope?a=222&b=213&_xc=just%20a%20test">here</a> </p></li>
</ul> </ul>
<p> And now a paragraph with <a href="http://www.zope-rocks.org">Link 1</a> and
<a href="http://www.zope-is-kewl.com">Link 2</a> and <a href="http://www.freshmeat.net">one more link - yeah.</a></p>
</body> </body>
</html> </html>
...@@ -16,3 +16,9 @@ This is LinkTest ...@@ -16,3 +16,9 @@ This is LinkTest
- please click "here":http://www.zope.org:2001/%20/Members/zope?a=222&b=213&_xc=just%20a%20test - please click "here":http://www.zope.org:2001/%20/Members/zope?a=222&b=213&_xc=just%20a%20test
- please click "here", http://www.zope.org:2001/%20/Members/zope?a=222&b=213&_xc=just%20a%20test
And now a paragraph with "Link 1":http://www.zope-rocks.org and
"Link 2":http://www.zope-is-kewl.com and "one more link - yeah.":http://www.freshmeat.net
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment