From ec0c69c5c9f65ff440c9eb12e93ad33723d424f6 Mon Sep 17 00:00:00 2001 From: Andrzej Klajnert Date: Wed, 9 Sep 2020 13:55:12 +0200 Subject: [PATCH] Accept `#` sign in the URL. --- CHANGELOG.md | 6 ++++++ rich/highlighter.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4dc8bb0..52cc91ad 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). +## [6.1.2] - Unreleased + +### Changed + +- The `#` sign is accepted as part of a URL + ## [6.1.1] - 2020-09-07 ### Changed diff --git a/rich/highlighter.py b/rich/highlighter.py index 13fc0ac1..213252eb 100644 --- a/rich/highlighter.py +++ b/rich/highlighter.py @@ -79,7 +79,7 @@ class ReprHighlighter(RegexHighlighter): r"(?P0x[0-9a-f]*)", r"(?P\B(\/[\w\.\-\_\+]+)*\/)(?P[\w\.\-\_\+]*)?", r"(?b?\'\'\'.*?(?https?:\/\/[0-9a-zA-Z\$\-\_\+\!`\(\)\,\.\?\/\;\:\&\=\%]*)", + r"(?Phttps?:\/\/[0-9a-zA-Z\$\-\_\+\!`\(\)\,\.\?\/\;\:\&\=\%\#]*)", r"(?P[a-fA-F0-9]{8}\-[a-fA-F0-9]{4}\-[a-fA-F0-9]{4}\-[a-fA-F0-9]{4}\-[a-fA-F0-9]{12})", ] @@ -104,7 +104,7 @@ if __name__ == "__main__": # pragma: no cover console.print(" /foo/bar/baz/egg.py word") console.print("foo /foo/bar/baz/egg.py word") console.print("foo /foo/bar/ba._++z/egg+.py word") - console.print("https://example.org?foo=bar") + console.print("https://example.org?foo=bar#header") console.print(1234567.34) console.print(1 / 2)