summaryrefslogtreecommitdiff
path: root/src/xhtml.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2014-04-30 00:43:21 +0200
committermathieui <mathieui@mathieui.net>2014-04-30 00:43:21 +0200
commitc3dd20fc745b0f4c8fa402052182b5383afbb7f8 (patch)
treebc4fe8ec4c1604eb106133b5d589e13aa089e8ed /src/xhtml.py
parent5f0afab060aa84a1cd1a81ade027f80b580a291d (diff)
downloadpoezio-c3dd20fc745b0f4c8fa402052182b5383afbb7f8.tar.gz
poezio-c3dd20fc745b0f4c8fa402052182b5383afbb7f8.tar.bz2
poezio-c3dd20fc745b0f4c8fa402052182b5383afbb7f8.tar.xz
poezio-c3dd20fc745b0f4c8fa402052182b5383afbb7f8.zip
Fix #2510 (link displayed twice in xhtml-im)
- also, fix the /xhtml command that was nesting one <body/> too many
Diffstat (limited to 'src/xhtml.py')
-rw-r--r--src/xhtml.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/xhtml.py b/src/xhtml.py
index ed45ff53..33a89b5e 100644
--- a/src/xhtml.py
+++ b/src/xhtml.py
@@ -287,6 +287,7 @@ class XHTMLHandler(sax.ContentHandler):
self.attrs = []
self.list_state = []
self.is_pre = False
+ self.a_start = 0
@property
def result(self):
@@ -318,6 +319,7 @@ class XHTMLHandler(sax.ContentHandler):
name = name[1]
if name == 'a':
self.append_formatting('\x19u')
+ self.a_start = len(self.builder)
elif name == 'blockquote':
builder.append('“')
elif name == 'br':
@@ -363,7 +365,11 @@ class XHTMLHandler(sax.ContentHandler):
if name == 'a':
self.pop_formatting()
- if 'href' in attrs:
+ # do not display the link twice
+ text_elements = filter(lambda x: not x.startswith('\x19'),
+ self.builder[self.a_start:])
+ link_text = ''.join(text_elements).strip()
+ if 'href' in attrs and attrs['href'] != link_text:
builder.append(' (%s)' % trim(attrs['href']))
elif name == 'blockquote':
builder.append('”')