diff --git a/matrix/colors.py b/matrix/colors.py index 2f51936..3eeabb8 100644 --- a/matrix/colors.py +++ b/matrix/colors.py @@ -318,17 +318,24 @@ class Formatted(object): try: lexer = get_lexer_by_name(value) except ClassNotFound: - return colored_text_block( - string, - margin=margin, - color_pair=code_color_pair) + if G.CONFIG.look.code_blocks: + return colored_text_block( + string, + margin=margin, + color_pair=code_color_pair) + else: + return string_color_and_reset(string, + code_color_pair) try: style = get_style_by_name(G.CONFIG.look.pygments_style) except ClassNotFound: style = "native" - code_block = text_block(string, margin=margin) + if G.CONFIG.look.code_blocks: + code_block = text_block(string, margin=margin) + else: + code_block = string # highlight adds a newline to the end of the string, remove # it from the output diff --git a/matrix/config.py b/matrix/config.py index d16d456..4f28963 100644 --- a/matrix/config.py +++ b/matrix/config.py @@ -496,6 +496,17 @@ class MatrixConfig(WeechatConfig): "native", "Pygments style to use for highlighting source code blocks", ), + Option( + "code_blocks", + "boolean", + "", + 0, + 0, + "on", + ("Display preformatted code blocks as rectangular areas by " + "padding them with whitespace up to the length of the longest " + "line (with optional margin)"), + ), Option( "code_block_margin", "integer",