Make displaying preformatted code as blocks configurable.
This commit is contained in:
parent
26f7dae990
commit
dcc5a3e530
2 changed files with 23 additions and 5 deletions
|
@ -318,17 +318,24 @@ class Formatted(object):
|
||||||
try:
|
try:
|
||||||
lexer = get_lexer_by_name(value)
|
lexer = get_lexer_by_name(value)
|
||||||
except ClassNotFound:
|
except ClassNotFound:
|
||||||
return colored_text_block(
|
if G.CONFIG.look.code_blocks:
|
||||||
string,
|
return colored_text_block(
|
||||||
margin=margin,
|
string,
|
||||||
color_pair=code_color_pair)
|
margin=margin,
|
||||||
|
color_pair=code_color_pair)
|
||||||
|
else:
|
||||||
|
return string_color_and_reset(string,
|
||||||
|
code_color_pair)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
style = get_style_by_name(G.CONFIG.look.pygments_style)
|
style = get_style_by_name(G.CONFIG.look.pygments_style)
|
||||||
except ClassNotFound:
|
except ClassNotFound:
|
||||||
style = "native"
|
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
|
# highlight adds a newline to the end of the string, remove
|
||||||
# it from the output
|
# it from the output
|
||||||
|
|
|
@ -496,6 +496,17 @@ class MatrixConfig(WeechatConfig):
|
||||||
"native",
|
"native",
|
||||||
"Pygments style to use for highlighting source code blocks",
|
"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(
|
Option(
|
||||||
"code_block_margin",
|
"code_block_margin",
|
||||||
"integer",
|
"integer",
|
||||||
|
|
Loading…
Add table
Reference in a new issue