Skip to content

Commit 50a43e9

Browse files
joouhajonathanslenders
authored andcommitted
Allow zero-width-escape sequences in print_formatted_text
1 parent f3d33c3 commit 50a43e9

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/prompt_toolkit/renderer.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -799,12 +799,16 @@ def print_formatted_text(
799799
output.reset_attributes()
800800
last_attrs = attrs
801801

802-
# Eliminate carriage returns
803-
text = text.replace("\r", "")
804-
805-
# Assume that the output is raw, and insert a carriage return before
806-
# every newline. (Also important when the front-end is a telnet client.)
807-
output.write(text.replace("\n", "\r\n"))
802+
# Print escape sequences as raw output
803+
if "[ZeroWidthEscape]" in style_str:
804+
output.write_raw(text)
805+
else:
806+
# Eliminate carriage returns
807+
text = text.replace("\r", "")
808+
# Insert a carriage return before every newline (important when the
809+
# front-end is a telnet client).
810+
text = text.replace("\n", "\r\n")
811+
output.write(text)
808812

809813
# Reset again.
810814
output.reset_attributes()

0 commit comments

Comments
 (0)