From 60fde2a274e20e92f56e1e9b23515f4c4a995980 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Sat, 19 Sep 2020 14:02:20 +0100 Subject: [PATCH] Fix broken HTML encoding Missing to specify encoding can mess some clients which may break the file encoding or render it incorrectly. Example: file that loads ok locally, after upload to S3 gets broken if the encoding is not mentioned in file. Use of UTF-8 is a very good practice, but we still need to mention it. --- CHANGELOG.md | 6 ++++++ rich/console.py | 1 + tests/test_console.py | 6 +++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49d432b0..a0a2563d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ 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). +## [7.0.1] - unreleased + +### Changed + +- UTF-8 encoding is now mentioned in HTML head section + ## [7.0.0] - 2020-09-18 ### Added diff --git a/rich/console.py b/rich/console.py index adf62a25..c5b7585b 100644 --- a/rich/console.py +++ b/rich/console.py @@ -56,6 +56,7 @@ OverflowMethod = Literal["fold", "crop", "ellipsis", "ignore"] CONSOLE_HTML_FORMAT = """\ + \n\n\n\n \n
foo Click\n
\n
\n\n\n' + expected = '\n\n\n\n\n\n\n \n
foo Click\n
\n
\n\n\n' assert html == expected @@ -259,7 +259,7 @@ def test_export_html_inline(): console = Console(record=True, width=100) console.print("[b]foo [link=https://example.org]Click[/link]") html = console.export_html(inline_styles=True) - expected = '\n\n\n\n\n\n \n
foo Click\n
\n
\n\n\n' + expected = '\n\n\n\n\n\n\n \n
foo Click\n
\n
\n\n\n' assert html == expected @@ -274,7 +274,7 @@ def test_save_text(): def test_save_html(): - expected = "\n\n\n\n\n\n \n
foo\n
\n
\n\n\n" + expected = "\n\n\n\n\n\n\n \n
foo\n
\n
\n\n\n" console = Console(record=True, width=100) console.print("foo") with tempfile.TemporaryDirectory() as path: