Skip to content

Commit

Permalink
Merge pull request Textualize#1335 from willmcgugan/span-sort
Browse files Browse the repository at this point in the history
fix for markup span sorting
  • Loading branch information
willmcgugan authored Jul 9, 2021
2 parents 0c0c90a + b671b34 commit 8a8a463
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added precision argument to filesize.decimal
- Added separator argument to filesize.decimal

### Fixed

- Fixed issue with adjoining color tags https://github.com/willmcgugan/rich/issues/1334

## [10.5.0] - 2021-05-07

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion rich/markup.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def pop_style(style_name: str) -> Tuple[int, Tag]:
if style:
append_span(_Span(start, text_length, style))

text.spans = sorted(spans, key=attrgetter("start", "end"))
text.spans = sorted(spans[::-1], key=attrgetter("start"))
return text


Expand Down
6 changes: 6 additions & 0 deletions tests/test_markup.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ def test_render_overlap():
]


def test_adjoint():
result = render("[red][blue]B[/blue]R[/red]")
print(repr(result))
assert result.spans == [Span(0, 2, "red"), Span(0, 1, "blue")]


def test_render_close():
result = render("[bold]X[/]Y")
assert str(result) == "XY"
Expand Down

0 comments on commit 8a8a463

Please sign in to comment.