← mined_oracle

rich_2290

failed WRONG_FIX UNSUBMITTED wrong_fix_unsubmitted(None) · 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
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
 The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
+## [12.4.4] - 2022-05-24
+
+### Changed
+
+- Added clipping per line to SVG output to avoid box characters overlapping
+- Optimized SVG output
+
 ## [12.4.3] - 2022-05-23
 
 ### Changed
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -2,7 +2,7 @@
 name = "rich"
 homepage = "https://github.com/willmcgugan/rich"
 documentation = "https://rich.readthedocs.io/en/latest/"
-version = "12.4.3"
+version = "12.4.4"
 description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal"
 authors = ["Will McGugan <willmcgugan@gmail.com>"]
 license = "MIT"
--- a/rich/_export_format.py
+++ b/rich/_export_format.py
@@ -61,6 +61,7 @@ CONSOLE_SVG_FORMAT = """\
     <clipPath id="{unique_id}-clip-terminal">
       <rect x="0" y="0" width="{terminal_width}" height="{terminal_height}" />
     </clipPath>
+    {lines}
     </defs>
 
     {chrome}
--- a/rich/console.py
+++ b/rich/console.py
@@ -2330,11 +2330,7 @@ class Console:
             )
 
         with self._record_buffer_lock:
-            segments = list(
-                Segment.filter_control(
-                    Segment.simplify(self._record_buffer),
-                )
-            )
+            segments = list(Segment.filter_control(self._record_buffer))
             if clear:
                 self._record_buffer.clear()
 
@@ -2383,6 +2379,7 @@ class Console:
                             y=y * line_height + 1.5,
                             width=char_width * text_length,
                             height=line_height + 0.25,
+                            shape_rendering="crispEdges",
                         )
                     )
 
@@ -2395,10 +2392,19 @@ class Console:
                             x=x * char_width,
                             y=y * line_height + char_height,
                             textLength=char_width * len(text),
+                            clip_path=f"url(#{unique_id}-line-{y})",
                         )
                     )
                 x += cell_len(text)
 
+        line_offsets = [line_no * line_height + 1.5 for line_no in range(y)]
+        lines = "\n".join(
+            f"""<clipPath id="{unique_id}-line-{line_no}">
+    {make_tag("rect", x=0, y=offset, width=char_width * width, height=line_height + 0.25)}
+            </clipPath>"""
+            for line_no, offset in enumerate(line_offsets)
+        )
+
         styles = "\n".join(
             f".{unique_id}-r{rule_no} {{ {css} }}" for css, rule_no in classes.items()
         )
@@ -2443,8 +2449,8 @@ class Console:
             char_width=char_width,
             char_height=char_height,
             line_height=line_height,
-            terminal_width=char_width * width,
-            terminal_height=(y + 1) * line_height,
+            terminal_width=char_width * width - 1,
+            terminal_height=(y + 1) * line_height - 1,
             width=terminal_width + margin_width,
             height=terminal_height + margin_height,
             terminal_x=margin_left + padding_left,
@@ -2453,6 +2459,7 @@ class Console:
             chrome=chrome,
             backgrounds=backgrounds,
             matrix=matrix,
+            lines=lines,
         )
         return svg
 

Test output

show
...................F
=================================== FAILURES ===================================
_______________________________ test_print_json ________________________________

    def test_print_json():
        console = Console(file=io.StringIO(), color_system="truecolor")
        console.print_json('[false, true, null, "foo"]', indent=4)
        result = console.file.getvalue()
        print(repr(result))
        expected = '\x1b[1m[\x1b[0m\n    \x1b[3;91mfalse\x1b[0m,\n    \x1b[3;92mtrue\x1b[0m,\n    \x1b[3;35mnull\x1b[0m,\n    \x1b[32m"foo"\x1b[0m\n\x1b[1m]\x1b[0m\n'
>       assert result == expected
E       AssertionError: assert '\x1b[1m[\x1b...[1m]\x1b[0m\n' == '\x1b[1m[\x1b...[1m]\x1b[0m\n'
E         
E           [
E         -     false,
E         ?        ---
E         +     false,
E         -     true,
E         ?        ---...
E         
E         ...Full output truncated (7 lines hidden), use '-vv' to show

tests/test_console.py:205: AssertionError
----------------------------- Captured stdout call -----------------------------
'\x1b[1m[\x1b[0m\n    \x1b[3mfalse\x1b[0m,\n    \x1b[3mtrue\x1b[0m,\n    \x1b[3mnull\x1b[0m,\n    "foo"\n\x1b[1m]\x1b[0m\n'
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
1 failed, 19 passed in 0.19s