Skip to content

Commit

Permalink
Merge pull request #1793 from willmcgugan/escape_at
Browse files Browse the repository at this point in the history
fix at escape
  • Loading branch information
willmcgugan committed Jan 2, 2022
2 parents 1d5152e + e839bfb commit 2ba277a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

## [10.16.2] - 2021-01-02

### Fixed

- Fixed @ not being escaped in markup

## [10.16.1] - 2021-12-15

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "rich"
homepage = "https://github.com/willmcgugan/rich"
documentation = "https://rich.readthedocs.io/en/latest/"
version = "10.16.1"
version = "10.16.2"
description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal"
authors = ["Will McGugan <willmcgugan@gmail.com>"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion rich/markup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def markup(self) -> str:


def escape(
markup: str, _escape: _EscapeSubMethod = re.compile(r"(\\*)(\[[a-z#\/].*?\])").sub
markup: str, _escape: _EscapeSubMethod = re.compile(r"(\\*)(\[[a-z#\/@].*?\])").sub
) -> str:
"""Escapes text so that it won't be interpreted as markup.
Expand Down
7 changes: 7 additions & 0 deletions tests/test_markup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ def test_re_match():
assert RE_TAGS.match("[color(1)]")
assert RE_TAGS.match("[#ff00ff]")
assert RE_TAGS.match("[/]")
assert RE_TAGS.match("[@]")
assert RE_TAGS.match("[@foo]")
assert RE_TAGS.match("[@foo=bar]")


def test_escape():
Expand All @@ -32,6 +35,10 @@ def test_escape():
assert escape("[5]") == "[5]"
assert escape("\\[5]") == "\\[5]"

# Test @ escape
assert escape("[@foo]") == "\\[@foo]"
assert escape("[@]") == "\\[@]"


def test_render_escape():
console = Console(width=80, color_system=None)
Expand Down

0 comments on commit 2ba277a

Please sign in to comment.