← oracle_full

rich_3063

resolved RESOLVED UNSUBMITTED PASS · None tool calls · 0 s · Textualize/rich

Task input

Fix escaping trailing backslash

Fixes https://github.com/Textualize/rich/issues/2987

Tool calls (0)

#ToolArgumentsResult
No trace captured.

Patch

--- a/rich/markup.py
+++ b/rich/markup.py
@@ -64,6 +64,9 @@ def escape_backslashes(match: Match[str]) -> str:
         return f"{backslashes}{backslashes}\\{text}"
 
     markup = _escape(escape_backslashes, markup)
+    if markup.endswith("\\") and not markup.endswith("\\\\"):
+        return markup + "\\"
+
     return markup
 
 
@@ -226,7 +229,6 @@ def pop_style(style_name: str) -> Tuple[int, Tag]:
 
 
 if __name__ == "__main__":  # pragma: no cover
-
     MARKUP = [
         "[red]Hello World[/red]",
         "[magenta]Hello [b]World[/b]",

Test output

show
.....................                                                    [100%]
21 passed in 0.12s