Commit 1cddf0c9 authored by Andreas Jung's avatar Andreas Jung

fix for collector #2276. Absolute URLs confused the regex for handling

:img:
parent 6ba7e752
......@@ -108,30 +108,34 @@ class DocumentWithImages(DocumentClass):
expr2=re.compile('\"([ _a-zA-Z0-9*.:/;,\-\n\~]+)\":img:([a-zA-Z0-9\-.:/;,\n\~]+):([a-zA-Z0-9\-.:/;,\n\~]+)').search
):
# Warning: the regex are getting confused when the string after :img:
# is an URL containing ":" (Collector #2276)
r = expr2(s)
if r:
# Warning: the regex are getting confused when the string after :img:
# is an URL containing ":" (Collector #2276)
# Ugly workaround: check if have an absolute URL here. Not a cool solution,
# but it works !
r = expr2(s)
if not r.group(2) in ['http','file','ftp']:
startt, endt = r.span(1)
startk, endk = r.span(2)
starth, endh = r.span(3)
start, end = r.span()
key = s[startk:endk]
return (StructuredTextImage(s[startt:endt], href=s[starth:endh], key=s[startk:endk]),
start, end)
r=expr1(s)
if r:
startt, endt = r.span(1)
startk, endk = r.span(2)
starth, endh = r.span(3)
starth, endh = r.span(2)
start, end = r.span()
return (StructuredTextImage(s[startt:endt], href=s[starth:endh], key=s[startk:endk]),
return (StructuredTextImage(s[startt:endt], href=s[starth:endh]),
start, end)
else:
r=expr1(s)
if r:
startt, endt = r.span(1)
starth, endh = r.span(2)
start, end = r.span()
return (StructuredTextImage(s[startt:endt], href=s[starth:endh]),
start, end)
return None
return None
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