← mined_oracle

rich_2188

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

Task input

(not found in data/tasks.jsonl)

Tool calls (0)

#ToolArgumentsResult
No trace captured.

Patch

--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 ### Fixed
 
 - Fall back to `sys.__stderr__` on POSIX systems when trying to get the terminal size (fix issues when Rich is piped to another process)
+- Fixed markup escaping issue https://github.com/Textualize/rich/issues/2187
 
 ## [12.2.0] - 2022-04-05
 
--- a/rich/markup.py
+++ b/rich/markup.py
@@ -46,7 +46,8 @@ _EscapeSubMethod = Callable[[_ReSubCallable, str], str]  # Sub method of a compi
 
 
 def escape(
-    markup: str, _escape: _EscapeSubMethod = re.compile(r"(\\*)(\[[a-z#\/@].*?\])").sub
+    markup: str,
+    _escape: _EscapeSubMethod = re.compile(r"(\\*)(\[[a-z#/@][^[]*?])").sub,
 ) -> str:
     """Escapes text so that it won't be interpreted as markup.
 

Test output

show
....................                                                     [100%]
=============================== warnings summary ===============================
tests/test_markup.py:147
  /private/tmp/swe_work/mined_oracle/rich_2188/b/workspace/tests/test_markup.py:147: SyntaxWarning: invalid escape sequence '\['
    result = str(render("[dim white]\[url=[/]"))

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
20 passed, 1 warning in 0.12s