diff --git a/CHANGELOG.md b/CHANGELOG.md index 61d5cc8d7..eb07a4107 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ 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). +## [Unreleased] + +### Fixed + +- Fix tilde character (`~`) not included in link regex when printing to console https://github.com/Textualize/rich/issues/3057 ## [13.5.0] - 2023-07-29 diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 43165b0ee..40ad4666f 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -51,6 +51,7 @@ The following people have contributed to the development of Rich: - [Clément Robert](https://github.com/neutrinoceros) - [Brian Rutledge](https://github.com/bhrutledge) - [Tushar Sadhwani](https://github.com/tusharsadhwani) +- [Luca Salvarani](https://github.com/LukeSavefrogs) - [Paul Sanders](https://github.com/sanders41) - [Tim Savage](https://github.com/timsavage) - [Anthony Shaw](https://github.com/tonybaloney) diff --git a/rich/highlighter.py b/rich/highlighter.py index c2646794a..27714b25b 100644 --- a/rich/highlighter.py +++ b/rich/highlighter.py @@ -98,7 +98,7 @@ class ReprHighlighter(RegexHighlighter): r"(?P(?\B(/[-\w._+]+)*\/)(?P[-\w._+]*)?", r"(?b?'''.*?(?(file|https|http|ws|wss)://[-0-9a-zA-Z$_+!`(),.?/;:&=%#]*)", + r"(?P(file|https|http|ws|wss)://[-0-9a-zA-Z$_+!`(),.?/;:&=%#~]*)", ), ] diff --git a/tests/test_highlighter.py b/tests/test_highlighter.py index 804efb369..30851cf79 100644 --- a/tests/test_highlighter.py +++ b/tests/test_highlighter.py @@ -133,6 +133,16 @@ def test_wrong_type(): (" https://example.org ", [Span(1, 20, "repr.url")]), (" http://example.org ", [Span(1, 19, "repr.url")]), (" http://example.org/index.html ", [Span(1, 30, "repr.url")]), + (" http://example.org/index.html#anchor ", [Span(1, 37, "repr.url")]), + ( + " http://example.org/index.html?param1=value1 ", + [ + Span(31, 37, "repr.attrib_name"), + Span(38, 44, "repr.attrib_value"), + Span(1, 44, "repr.url"), + ], + ), + (" http://example.org/~folder ", [Span(1, 27, "repr.url")]), ("No place like 127.0.0.1", [Span(14, 23, "repr.ipv4")]), ("''", [Span(0, 2, "repr.str")]), ("'hello'", [Span(0, 7, "repr.str")]),