poezio_colors_to_html now takes full colors (\x19xxx}) to generate the xhtml code
(cherry picked from commit 2b9a43ce6a
)
This commit is contained in:
parent
2404358689
commit
f13d03c149
1 changed files with 14 additions and 12 deletions
26
src/xhtml.py
26
src/xhtml.py
|
@ -402,7 +402,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,)
|
||||
|
@ -411,17 +410,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]:
|
||||
|
|
Loading…
Reference in a new issue