frontends (tools/strings): fixXHTMLLinks skips internal anchors (links starting with "#")

fix bug 126
This commit is contained in:
souliane 2016-03-05 13:58:02 +01:00
commit 849683ec70

View file

@ -84,7 +84,7 @@ def fixXHTMLLinks(xhtml):
for match in re.finditer(r'<a( \w+="[^"]*")* ?/?>', xhtml):
tag = match.group(0)
url = re.search(r'href="([^"]*)"', tag)
if url:
if url and not url.group(1).startswith("#"): # skip internal anchor
if not re.search(r'target="([^"]*)"', tag): # no target
subs.append((tag, '<a target="_blank"%s' % tag[2:]))
if not re.match(r"^\w+://", url.group(1)): # no scheme