Make code block margin configurable.
This commit is contained in:
parent
a6cf2e1527
commit
26f7dae990
2 changed files with 16 additions and 4 deletions
|
@ -310,6 +310,8 @@ class Formatted(object):
|
||||||
G.CONFIG.color.untagged_code_bg
|
G.CONFIG.color.untagged_code_bg
|
||||||
)
|
)
|
||||||
|
|
||||||
|
margin = G.CONFIG.look.code_block_margin
|
||||||
|
|
||||||
if attributes["preformatted"]:
|
if attributes["preformatted"]:
|
||||||
# code block
|
# code block
|
||||||
|
|
||||||
|
@ -318,7 +320,7 @@ class Formatted(object):
|
||||||
except ClassNotFound:
|
except ClassNotFound:
|
||||||
return colored_text_block(
|
return colored_text_block(
|
||||||
string,
|
string,
|
||||||
margin=2,
|
margin=margin,
|
||||||
color_pair=code_color_pair)
|
color_pair=code_color_pair)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -326,10 +328,10 @@ class Formatted(object):
|
||||||
except ClassNotFound:
|
except ClassNotFound:
|
||||||
style = "native"
|
style = "native"
|
||||||
|
|
||||||
code_block = text_block(string, margin=2)
|
code_block = text_block(string, margin=margin)
|
||||||
|
|
||||||
# highlight adds a newline to the end of the string, remove it
|
# highlight adds a newline to the end of the string, remove
|
||||||
# from the output
|
# it from the output
|
||||||
highlighted_code = highlight(
|
highlighted_code = highlight(
|
||||||
code_block,
|
code_block,
|
||||||
lexer,
|
lexer,
|
||||||
|
|
|
@ -496,6 +496,16 @@ 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_block_margin",
|
||||||
|
"integer",
|
||||||
|
"",
|
||||||
|
0,
|
||||||
|
100,
|
||||||
|
"2",
|
||||||
|
("Number of spaces to add as a margin around around a code "
|
||||||
|
"block"),
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
network_options = [
|
network_options = [
|
||||||
|
|
Loading…
Add table
Reference in a new issue