Disable xhtml-im by default
This commit is contained in:
parent
7e2a98b0f5
commit
cb1abbd945
2 changed files with 21 additions and 10 deletions
|
@ -51,6 +51,16 @@ after_completion = ,
|
||||||
# highlighted if said by someone on a room
|
# highlighted if said by someone on a room
|
||||||
highlight_on =
|
highlight_on =
|
||||||
|
|
||||||
|
# XHTML-IM is an XMPP extension letting users send messages
|
||||||
|
# containing XHTML and CSS formating. We can use this to make
|
||||||
|
# colored text for example.
|
||||||
|
# It is disabled by default because this is only in an experimental
|
||||||
|
# state: you could miss some part of a message (mainly the URL)
|
||||||
|
# but you can still send colored messages. You just won’t be able te see
|
||||||
|
# the colors, though
|
||||||
|
# Set to true if you want to see colored messages
|
||||||
|
enable_xhtml_im = false
|
||||||
|
|
||||||
# Set a number for this setting.
|
# Set a number for this setting.
|
||||||
# The join OR status-change notices will be
|
# The join OR status-change notices will be
|
||||||
# displayed according to this number.
|
# displayed according to this number.
|
||||||
|
|
21
src/xhtml.py
21
src/xhtml.py
|
@ -26,11 +26,11 @@ poezio colors to xhtml code
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
from config import config
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
shell_colors_re = re.compile(r'(\[(?:\d+;)*(?:\d+m))')
|
shell_colors_re = re.compile(r'(\[(?:\d+;)*(?:\d+m))')
|
||||||
start_indent_re = re.compile(r'\[0;30m\[0;37m ')
|
start_indent_re = re.compile(r'\[0;30m\[0;37m ')
|
||||||
newline_indent_re = re.compile('\n\[0;37m ')
|
newline_indent_re = re.compile('\n\[0;37m ')
|
||||||
|
@ -41,14 +41,15 @@ def get_body_from_message_stanza(message):
|
||||||
poezio colors if there's an xhtml_im element, or
|
poezio colors if there's an xhtml_im element, or
|
||||||
the body (without any color) otherwise
|
the body (without any color) otherwise
|
||||||
"""
|
"""
|
||||||
xhtml_body = message['xhtml_im']
|
if config.get('enable_xhtml_im', 'false') == 'true':
|
||||||
if xhtml_body:
|
xhtml_body = message['xhtml_im']
|
||||||
try:
|
if xhtml_body:
|
||||||
shell_body = xhtml_code_to_shell_colors(xhtml_body)
|
try:
|
||||||
except OSError:
|
shell_body = xhtml_code_to_shell_colors(xhtml_body)
|
||||||
log.error('html parsing failed')
|
except OSError:
|
||||||
else:
|
log.error('html parsing failed')
|
||||||
return shell_colors_to_poezio_colors(shell_body)
|
else:
|
||||||
|
return shell_colors_to_poezio_colors(shell_body)
|
||||||
return message['body']
|
return message['body']
|
||||||
|
|
||||||
def clean_text(string):
|
def clean_text(string):
|
||||||
|
@ -133,7 +134,7 @@ def shell_colors_to_poezio_colors(string):
|
||||||
elif num == 1:
|
elif num == 1:
|
||||||
res += '\x19b'
|
res += '\x19b'
|
||||||
elif num >= 31 and num <= 37:
|
elif num >= 31 and num <= 37:
|
||||||
res += '\x19%d' % (num-30,)
|
res += '\x19%d' % ((num-30)%7,)
|
||||||
return res
|
return res
|
||||||
def remove_elinks_indent(string):
|
def remove_elinks_indent(string):
|
||||||
lines = string.split('\n')
|
lines = string.split('\n')
|
||||||
|
|
Loading…
Reference in a new issue