diff --git a/CHANGELOG.md b/CHANGELOG.md index bbd0167c3..19033811b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,16 @@ 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.2] - 2022-05-23 + +### Fixed + +- Fix for SVG on Firefox + +### Changed + +- Removed excess margin from SVG, tweaked cell sizes to better render block characters + ## [12.4.1] - 2022-05-08 ### Fixed diff --git a/pyproject.toml b/pyproject.toml index 71f4e9ac6..eca3f240b 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.1" +version = "12.4.2" 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 32aa71c91..d469bac26 100644 --- a/rich/_export_format.py +++ b/rich/_export_format.py @@ -50,7 +50,6 @@ .{unique_id}-title {{ font-size: 18px; - font-weight: bold; font-family: arial; }} @@ -60,7 +59,9 @@ {chrome} {backgrounds} - {matrix} + + {matrix} + """ diff --git a/rich/console.py b/rich/console.py index 2159d3c17..2f42b71a9 100644 --- a/rich/console.py +++ b/rich/console.py @@ -2282,18 +2282,18 @@ def get_svg_style(style: Style) -> str: width = self.width char_height = 20 - char_width = char_height * 0.62 - line_height = char_height * 1.32 + char_width = char_height * 0.61 + line_height = char_height * 1.22 - margin_top = 20 - margin_right = 16 - margin_bottom = 20 - margin_left = 16 + margin_top = 1 + margin_right = 1 + margin_bottom = 1 + margin_left = 1 padding_top = 40 - padding_right = 12 + padding_right = 8 padding_bottom = 12 - padding_left = 12 + padding_left = 8 padding_width = padding_left + padding_right padding_height = padding_top + padding_bottom @@ -2385,16 +2385,18 @@ def stringify(value: object) -> str: height=line_height + 1, ) ) - text_group.append( - make_tag( - "tspan", - escape_text(text), - _class=f"{unique_id}-{class_name}", - x=x * char_width, - y=y * line_height + char_height, - textLength=char_width * len(text), + + if text != " " * len(text): + text_group.append( + make_tag( + "text", + escape_text(text), + _class=f"{unique_id}-{class_name}", + x=x * char_width, + y=y * line_height + char_height, + textLength=char_width * len(text), + ) ) - ) x += cell_len(text) styles = "\n".join( @@ -2421,7 +2423,7 @@ def stringify(value: object) -> str: if title: chrome += make_tag( "text", - title, + escape_text(title), _class=f"{unique_id}-title", fill=title_color, text_anchor="middle", @@ -2429,9 +2431,11 @@ def stringify(value: object) -> str: y=margin_top + char_height + 6, ) chrome += f""" - - - + + + + + """ svg = code_format.format( diff --git a/tests/test_console.py b/tests/test_console.py index 007cd2810..35f3cbf3c 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 foo Click                                                                                           \n\n \n\n' +EXPECTED_SVG = '\n \n \n Rich\n \n \n \n \n \n \n \n \n \n fooClick\n\n \n \n\n' def test_export_svg():