From e8032fcf90e258b2d659d850efa60a2b2addbfad Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Mon, 23 May 2022 16:19:19 +0100 Subject: [PATCH 1/2] tweak to blocks --- rich/console.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rich/console.py b/rich/console.py index 2f42b71a9..94dac8afd 100644 --- a/rich/console.py +++ b/rich/console.py @@ -2380,9 +2380,9 @@ def stringify(value: object) -> str: "rect", fill=background, x=x * char_width, - y=y * line_height, - width=char_width * text_length + 1, - height=line_height + 1, + y=y * line_height + 1.5, + width=char_width * text_length + 0.5, + height=line_height + 0.25, ) ) From 2d441954825ce653528be677466cf7d687c90ea0 Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Mon, 23 May 2022 16:54:07 +0100 Subject: [PATCH 2/2] svg fixes --- CHANGELOG.md | 7 +++++++ pyproject.toml | 2 +- rich/_export_format.py | 9 ++++++++- rich/console.py | 10 ++++++---- tests/test_console.py | 2 +- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19033811b..ca4c40660 100644 --- 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.3] - 2022-05-23 + +### Changed + +- Further tweaks to SVG character matrix +- Added clip rect to SVG to prevent box characters overlapping bottom of terminal + ## [12.4.2] - 2022-05-23 ### Fixed diff --git a/pyproject.toml b/pyproject.toml index eca3f240b..e922561cf 100644 --- 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.2" +version = "12.4.3" description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" authors = ["Will McGugan "] license = "MIT" diff --git a/rich/_export_format.py b/rich/_export_format.py index d469bac26..028e83366 100644 --- a/rich/_export_format.py +++ b/rich/_export_format.py @@ -56,8 +56,15 @@ {styles} + + + + + + + {chrome} - + {backgrounds} {matrix} diff --git a/rich/console.py b/rich/console.py index 94dac8afd..9e2b5fe30 100644 --- a/rich/console.py +++ b/rich/console.py @@ -2292,7 +2292,7 @@ def get_svg_style(style: Style) -> str: padding_top = 40 padding_right = 8 - padding_bottom = 12 + padding_bottom = 8 padding_left = 8 padding_width = padding_left + padding_right @@ -2381,7 +2381,7 @@ def stringify(value: object) -> str: fill=background, x=x * char_width, y=y * line_height + 1.5, - width=char_width * text_length + 0.5, + width=char_width * text_length, height=line_height + 0.25, ) ) @@ -2416,7 +2416,7 @@ def stringify(value: object) -> str: y=margin_top, width=terminal_width, height=terminal_height, - rx=12, + rx=8, ) title_color = _theme.foreground_color.hex @@ -2431,7 +2431,7 @@ def stringify(value: object) -> str: y=margin_top + char_height + 6, ) chrome += f""" - + @@ -2443,6 +2443,8 @@ def stringify(value: object) -> str: char_width=char_width, char_height=char_height, line_height=line_height, + terminal_width=char_width * width, + terminal_height=(y + 1) * line_height, width=terminal_width + margin_width, height=terminal_height + margin_height, terminal_x=margin_left + padding_left, diff --git a/tests/test_console.py b/tests/test_console.py index 35f3cbf3c..e09b23859 100644 --- a/tests/test_console.py +++ b/tests/test_console.py @@ -494,7 +494,7 @@ def test_export_html_inline(): assert html == expected -EXPECTED_SVG = '\n \n \n Rich\n \n \n \n \n \n \n \n \n \n fooClick\n\n \n \n\n' +EXPECTED_SVG = '\n \n \n\n \n \n \n \n \n\n Rich\n \n \n \n \n \n \n \n \n \n fooClick\n\n \n \n\n' def test_export_svg():