[Cdd-commits] r1320 - blends/trunk/webtools
CDD Subversion Commit
noreply at alioth.debian.org
Tue Jan 20 14:28:20 UTC 2009
Author: tille
Date: Tue Jan 20 14:28:20 2009
New Revision: 1320
Modified:
blends/trunk/webtools/blendstasktools.py
Log:
Enable '&' in links inside descriptions
Modified: blends/trunk/webtools/blendstasktools.py
==============================================================================
--- blends/trunk/webtools/blendstasktools.py (original)
+++ blends/trunk/webtools/blendstasktools.py Tue Jan 20 14:28:20 2009
@@ -153,8 +153,25 @@
# This is to sanitize output for XHTML pages. --David
# Leave out the first space (line[1:]) instead of strip() because strip
# removes wanted indentation of pre statements
- line = line[1:].replace("&", "&").replace("<", "<").replace(">", ">") + ' \n'
- LongDesc += re.sub('([fh]t?tp://[-./\w?=~;]+)', '<a href="\\1">\\1</a>', line)
+ line = line[1:] + ' \n'
+ if re.compile("[fh]t?tp://").search(line):
+ # some descriptions put URLs in '<>' which is unneeded and might
+ # confuse the parsing of '&' in URLs which is needed sometimes
+ line = re.sub('<*([fh]t?tp://[-./\w?=~;&]+)>*', '<a href="\\1">\\1</a>', line)
+ else:
+ # This code assumes that in description lines with an URL no
+ # other '<' or '>' occures which is not guaranteed but for
+ # the moment better than breaking links containing '&' characters
+ line = line.replace("<", "<").replace(">", ">")
+ # Try to replace & before '<a' and after </a>
+ if re.compile("&").search(line):
+ if not re.compile("<a ").search(line):
+ # if there is no link in the line it is simple ...
+ line = line.replace("&", "&")
+ else:
+ line = re.sub('&(.*<a )', '\\&\\1', line)
+ line = re.sub('(</a>.*)&', '\\1\\&', line)
+ LongDesc += line
if pre == 1:
LongDesc += "</pre>\n"
return (ShortDesc, LongDesc)
More information about the Cdd-commits
mailing list