fix: enable word wrapping for syntax-highlighted code output
Long code lines were clipped at the terminal width, making them unreadable. Pass word_wrap=True to all Syntax() calls so lines wrap instead of being cut off.
This commit is contained in:
@@ -83,12 +83,20 @@ def render(
|
||||
except (SyntaxError, ValueError):
|
||||
log_debug(options.debug, "render: invalid JSON, falling back to syntax")
|
||||
renderable = Syntax(
|
||||
content, "json", theme=options.theme, line_numbers=line_numbers
|
||||
content,
|
||||
"json",
|
||||
theme=options.theme,
|
||||
line_numbers=line_numbers,
|
||||
word_wrap=True,
|
||||
)
|
||||
else:
|
||||
try:
|
||||
renderable = Syntax(
|
||||
content, file_type, theme=options.theme, line_numbers=line_numbers
|
||||
content,
|
||||
file_type,
|
||||
theme=options.theme,
|
||||
line_numbers=line_numbers,
|
||||
word_wrap=True,
|
||||
)
|
||||
except Exception:
|
||||
log_debug(
|
||||
@@ -96,7 +104,11 @@ def render(
|
||||
f"render: unknown lexer {file_type!r}, falling back to plain text",
|
||||
)
|
||||
renderable = Syntax(
|
||||
content, "text", theme=options.theme, line_numbers=line_numbers
|
||||
content,
|
||||
"text",
|
||||
theme=options.theme,
|
||||
line_numbers=line_numbers,
|
||||
word_wrap=True,
|
||||
)
|
||||
|
||||
padded = Padding(renderable, (1, 2))
|
||||
|
||||
Reference in New Issue
Block a user