Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make repr tag highlighting greedy #2565

Merged
merged 6 commits into from Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Bumped minimum Python version to 3.7 https://github.com/Textualize/rich/pull/2567
- Pretty-printing of "tagged" `__repr__` results is now greedy when matching tags https://github.com/Textualize/rich/pull/2565

## [12.6.0] - 2022-10-02

Expand Down
22 changes: 21 additions & 1 deletion tests/test_highlighter.py
Expand Up @@ -5,10 +5,10 @@
import pytest

from rich.highlighter import (
ISO8601Highlighter,
JSONHighlighter,
NullHighlighter,
ReprHighlighter,
ISO8601Highlighter,
)
from rich.text import Span, Text

Expand All @@ -30,6 +30,26 @@ def test_wrong_type():
Span(4, 5, "repr.tag_end"),
],
),
(
"<foo: 23>",
[
Span(0, 1, "repr.tag_start"),
Span(1, 5, "repr.tag_name"),
Span(5, 8, "repr.tag_contents"),
Span(8, 9, "repr.tag_end"),
Span(6, 8, "repr.number"),
],
),
(
"<foo: <bar: 23>>",
[
Span(0, 1, "repr.tag_start"),
Span(1, 5, "repr.tag_name"),
Span(5, 15, "repr.tag_contents"),
Span(15, 16, "repr.tag_end"),
Span(12, 14, "repr.number"),
],
),
(
"False True None",
[
Expand Down