Commit 323d2889 authored by Chris McDonough's avatar Chris McDonough

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.
parent e1cb047f
......@@ -951,12 +951,13 @@ class DocumentClass:
## 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)
......
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