Skip to content

Commit 2ba277a

Browse files
authored
Merge pull request #1793 from willmcgugan/escape_at
fix at escape
2 parents 1d5152e + e839bfb commit 2ba277a

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [10.16.2] - 2021-01-02
9+
10+
### Fixed
11+
12+
- Fixed @ not being escaped in markup
13+
814
## [10.16.1] - 2021-12-15
915

1016
### Fixed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "rich"
33
homepage = "https://github.com/willmcgugan/rich"
44
documentation = "https://rich.readthedocs.io/en/latest/"
5-
version = "10.16.1"
5+
version = "10.16.2"
66
description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal"
77
authors = ["Will McGugan <[email protected]>"]
88
license = "MIT"

rich/markup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def markup(self) -> str:
4747

4848

4949
def escape(
50-
markup: str, _escape: _EscapeSubMethod = re.compile(r"(\\*)(\[[a-z#\/].*?\])").sub
50+
markup: str, _escape: _EscapeSubMethod = re.compile(r"(\\*)(\[[a-z#\/@].*?\])").sub
5151
) -> str:
5252
"""Escapes text so that it won't be interpreted as markup.
5353

tests/test_markup.py

+7
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ def test_re_match():
2121
assert RE_TAGS.match("[color(1)]")
2222
assert RE_TAGS.match("[#ff00ff]")
2323
assert RE_TAGS.match("[/]")
24+
assert RE_TAGS.match("[@]")
25+
assert RE_TAGS.match("[@foo]")
26+
assert RE_TAGS.match("[@foo=bar]")
2427

2528

2629
def test_escape():
@@ -32,6 +35,10 @@ def test_escape():
3235
assert escape("[5]") == "[5]"
3336
assert escape("\\[5]") == "\\[5]"
3437

38+
# Test @ escape
39+
assert escape("[@foo]") == "\\[@foo]"
40+
assert escape("[@]") == "\\[@]"
41+
3542

3643
def test_render_escape():
3744
console = Console(width=80, color_system=None)

0 commit comments

Comments
 (0)