diff options
author | Florent Le Coz <louiz@louiz.org> | 2011-04-04 19:19:27 +0200 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2011-04-04 19:19:27 +0200 |
commit | cb1abbd9451af2062cc8f71f51e0ba903fa2f749 (patch) | |
tree | a4cd6f0619e6f4c47c3e8953e237c463ed8c7eb4 /src | |
parent | 7e2a98b0f5e19abb945ee2f316b4717d269bd3bf (diff) | |
download | poezio-cb1abbd9451af2062cc8f71f51e0ba903fa2f749.tar.gz poezio-cb1abbd9451af2062cc8f71f51e0ba903fa2f749.tar.bz2 poezio-cb1abbd9451af2062cc8f71f51e0ba903fa2f749.tar.xz poezio-cb1abbd9451af2062cc8f71f51e0ba903fa2f749.zip |
Disable xhtml-im by default
Diffstat (limited to 'src')
-rw-r--r-- | src/xhtml.py | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/xhtml.py b/src/xhtml.py index 55582066..a9f0af60 100644 --- a/src/xhtml.py +++ b/src/xhtml.py @@ -26,11 +26,11 @@ poezio colors to xhtml code import re import subprocess +from config import config import logging log = logging.getLogger(__name__) - shell_colors_re = re.compile(r'(\[(?:\d+;)*(?:\d+m))') start_indent_re = re.compile(r'\[0;30m\[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 the body (without any color) otherwise """ - xhtml_body = message['xhtml_im'] - if xhtml_body: - try: - shell_body = xhtml_code_to_shell_colors(xhtml_body) - except OSError: - log.error('html parsing failed') - else: - return shell_colors_to_poezio_colors(shell_body) + if config.get('enable_xhtml_im', 'false') == 'true': + xhtml_body = message['xhtml_im'] + if xhtml_body: + try: + shell_body = xhtml_code_to_shell_colors(xhtml_body) + except OSError: + log.error('html parsing failed') + else: + return shell_colors_to_poezio_colors(shell_body) return message['body'] def clean_text(string): @@ -133,7 +134,7 @@ def shell_colors_to_poezio_colors(string): elif num == 1: res += '\x19b' elif num >= 31 and num <= 37: - res += '\x19%d' % (num-30,) + res += '\x19%d' % ((num-30)%7,) return res def remove_elinks_indent(string): lines = string.split('\n') |