summaryrefslogtreecommitdiff
path: root/src/xhtml.py
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2011-11-07 19:56:03 +0100
committerFlorent Le Coz <louiz@louiz.org>2011-11-07 19:56:03 +0100
commit2b9a43ce6a5fa6ad93ab570a99d4d92337a40110 (patch)
tree968c0fdf597d5608b003125e0f75f3a5eeacf8db /src/xhtml.py
parent60b58301d3ba9e1df1fb4edbb98c5910d0458a36 (diff)
downloadpoezio-2b9a43ce6a5fa6ad93ab570a99d4d92337a40110.tar.gz
poezio-2b9a43ce6a5fa6ad93ab570a99d4d92337a40110.tar.bz2
poezio-2b9a43ce6a5fa6ad93ab570a99d4d92337a40110.tar.xz
poezio-2b9a43ce6a5fa6ad93ab570a99d4d92337a40110.zip
poezio_colors_to_html now takes full colors (\x19xxx}) to generate the xhtml code
Diffstat (limited to 'src/xhtml.py')
-rw-r--r--src/xhtml.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/xhtml.py b/src/xhtml.py
index 70e17423..973a4d18 100644
--- a/src/xhtml.py
+++ b/src/xhtml.py
@@ -400,7 +400,6 @@ def poezio_colors_to_html(string):
attr_char = string[next_attr_char+1].lower()
if next_attr_char != 0:
res += string[:next_attr_char]
- string = string[next_attr_char+2:]
if attr_char == 'o':
for elem in opened_elements[::-1]:
res += '</%s>' % (elem,)
@@ -409,17 +408,20 @@ def poezio_colors_to_html(string):
if 'strong' not in opened_elements:
opened_elements.append('strong')
res += '<strong>'
- elif attr_char in digits:
- number = int(attr_char)
- if number in number_to_color_names:
- 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='color: %s'>" % (number_to_color_names[number])
+ if attr_char in digits:
+ number_str = string[next_attr_char+1:string.find('}', next_attr_char)]
+ number = int(number_str)
+ 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='color: %s'>" % (ncurses_color_to_html(number),)
+ string = string[next_attr_char+len(number_str)+2:]
+ else:
+ string = string[next_attr_char+2:]
next_attr_char = string.find('\x19')
res += string
for elem in opened_elements[::-1]: