From bf202895d91dab4707c1f29c89e79ce8ee82f859 Mon Sep 17 00:00:00 2001 From: Chris Duf Date: Tue, 3 Dec 2024 15:15:05 +0100 Subject: [PATCH 1/3] when using inline HTML styles, directly apply rules to anchors When exporting captured output to HTML, using inline CSS styles, linked text is formatted as: text It seems that Web browsers will then render the linked text with the default style for unvisited links (typically blue). The CSS rules are, however, correctly applied if put directly on the anchor element: text Tested with Firefox 128.4 and Google Chrome 131. --- rich/console.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rich/console.py b/rich/console.py index 3ec9a8aab..7182c7b42 100644 --- a/rich/console.py +++ b/rich/console.py @@ -2238,8 +2238,14 @@ def export_html( if style: rule = style.get_html_style(_theme) if style.link: - text = f'{text}' - text = f'{text}' if rule else text + if rule: + text = ( + f'{text}' + ) + else: + text = f'{text}' + elif rule: + text = f'{text}' append(text) else: styles: Dict[str, int] = {} From b6e0e1ddb908556ed1c0618625fb84718b45d5ba Mon Sep 17 00:00:00 2001 From: Chris Duf Date: Tue, 3 Dec 2024 16:06:05 +0100 Subject: [PATCH 2/3] add Christophe Dufaza to CONTRIBUTORS file --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index d8985ca13..b65df343f 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -15,6 +15,7 @@ The following people have contributed to the development of Rich: - [Jim Crist-Harif](https://github.com/jcrist) - [Ed Davis](https://github.com/davised) - [Pete Davison](https://github.com/pd93) +- [Christophe Dufaza](https://github.com/dottspina) - [James Estevez](https://github.com/jstvz) - [Jonathan Eunice](https://github.com/jonathan-3play) - [Aryaz Eghbali](https://github.com/AryazE) From 4857e7bbc8dd0ce2ac9d129555a072983e4411d7 Mon Sep 17 00:00:00 2001 From: Chris Duf Date: Tue, 3 Dec 2024 16:07:26 +0100 Subject: [PATCH 3/3] add PR 3580 to CHANGELOG Ref: - https://github.com/Textualize/rich/pull/3580 --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c7332fee..2d23d4410 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ 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). +## [13.9.5] - 2024-12-03 + +### Fixed + +- When using inline HTML styles, directly apply rules to anchors https://github.com/Textualize/rich/pull/3580 + ## [13.9.4] - 2024-11-01 ### Changed