mirror of https://github.com/Textualize/rich.git
Fix [BUG] @ breaks highlighting in hyperlink #3327
Changes - 1. Added '@' in rich.highlighter:ReprHighlighter url regex pattern. 2. Added a test case in test_highlighter for the url with '@'.
This commit is contained in:
parent
e1e6d745f6
commit
f591471cf0
|
@ -98,7 +98,7 @@ class ReprHighlighter(RegexHighlighter):
|
||||||
r"(?P<number>(?<!\w)\-?[0-9]+\.?[0-9]*(e[-+]?\d+?)?\b|0x[0-9a-fA-F]*)",
|
r"(?P<number>(?<!\w)\-?[0-9]+\.?[0-9]*(e[-+]?\d+?)?\b|0x[0-9a-fA-F]*)",
|
||||||
r"(?P<path>\B(/[-\w._+]+)*\/)(?P<filename>[-\w._+]*)?",
|
r"(?P<path>\B(/[-\w._+]+)*\/)(?P<filename>[-\w._+]*)?",
|
||||||
r"(?<![\\\w])(?P<str>b?'''.*?(?<!\\)'''|b?'.*?(?<!\\)'|b?\"\"\".*?(?<!\\)\"\"\"|b?\".*?(?<!\\)\")",
|
r"(?<![\\\w])(?P<str>b?'''.*?(?<!\\)'''|b?'.*?(?<!\\)'|b?\"\"\".*?(?<!\\)\"\"\"|b?\".*?(?<!\\)\")",
|
||||||
r"(?P<url>(file|https|http|ws|wss)://[-0-9a-zA-Z$_+!`(),.?/;:&=%#~]*)",
|
r"(?P<url>(file|https|http|ws|wss)://[-0-9a-zA-Z$_+!`(),.?/;:&=%#~@]*)",
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -134,6 +134,7 @@ highlight_tests = [
|
||||||
(" http://example.org ", [Span(1, 19, "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 ", [Span(1, 30, "repr.url")]),
|
||||||
(" http://example.org/index.html#anchor ", [Span(1, 37, "repr.url")]),
|
(" http://example.org/index.html#anchor ", [Span(1, 37, "repr.url")]),
|
||||||
|
("https://www.youtube.com/@LinusTechTips", [Span(0, 38, "repr.url")]),
|
||||||
(
|
(
|
||||||
" http://example.org/index.html?param1=value1 ",
|
" http://example.org/index.html?param1=value1 ",
|
||||||
[
|
[
|
||||||
|
|
Loading…
Reference in New Issue