summaryrefslogtreecommitdiff
path: root/src/xhtml.py
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2012-07-29 03:36:05 +0200
committerFlorent Le Coz <louiz@louiz.org>2012-07-29 03:36:05 +0200
commit21eeef5c7b83e5c7106a18b12ba5f423d321e186 (patch)
treeb8e598b846e0d65b878a137de7ad0ed9aad5ae01 /src/xhtml.py
parentc9ea00b963bbaf68ce14fd87d4b97a0541b96b9a (diff)
downloadpoezio-21eeef5c7b83e5c7106a18b12ba5f423d321e186.tar.gz
poezio-21eeef5c7b83e5c7106a18b12ba5f423d321e186.tar.bz2
poezio-21eeef5c7b83e5c7106a18b12ba5f423d321e186.tar.xz
poezio-21eeef5c7b83e5c7106a18b12ba5f423d321e186.zip
Implement the sending of underlined text in xhtml-im messages (C-c u).
Note that a portion of text can NOT have a color AND be underlined at the same time, but it's not really tragic (see comment in source code).
Diffstat (limited to 'src/xhtml.py')
-rw-r--r--src/xhtml.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/xhtml.py b/src/xhtml.py
index 4d93a855..a36607d2 100644
--- a/src/xhtml.py
+++ b/src/xhtml.py
@@ -399,7 +399,12 @@ def poezio_colors_to_html(string):
Convert poezio colors to html makups
(e.g. \x191: <span style='color: red'>)
"""
- # TODO underlined
+ # XXX: You cannot underline AND use color on the same portion of your
+ # message (because both these things use a <span/> element, and the
+ # current way it is done, when you open a <span/> element, you close the
+ # previous one). Dectecting if a span is already opened, close it and
+ # reopen it with the same style PLUS the new style seems complicated.
+ # I'll keep it that way unless someone fixes that properly.
# a list of all opened elements, e.g. ['strong', 'span']
# So that we know what we need to close
@@ -418,6 +423,15 @@ def poezio_colors_to_html(string):
if 'strong' not in opened_elements:
opened_elements.append('strong')
res += '<strong>'
+ elif attr_char == 'u':
+ if 'strong' in opened_elements:
+ res += '</strong>'
+ opened_elements.remove('strong')
+ if 'span' in opened_elements:
+ res += '</span>'
+ else:
+ opened_elements.append('span')
+ res += "<span style='text-decoration:underline'>"
if attr_char in digits:
number_str = string[next_attr_char+1:string.find('}', next_attr_char)]
number = int(number_str)