Fix issue with markup escaping

This commit is contained in:
Darren Burns 2022-02-10 14:31:37 +00:00
parent ae5865eb79
commit 71325bb5bb
2 changed files with 14 additions and 9 deletions

View file

@ -1,7 +1,7 @@
import pytest
from rich.console import Console
from rich.markup import escape, MarkupError, _parse, render, Tag, RE_TAGS
from rich.markup import RE_TAGS, MarkupError, Tag, _parse, escape, render
from rich.text import Span
@ -139,6 +139,11 @@ def test_markup_error():
assert render("[foo]hello[/bar]")
def test_markup_escape():
result = str(render("[dim white]\[url=[/]"))
assert result == "[url="
def test_escape_escape():
# Escaped escapes (i.e. double backslash)should be treated as literal
result = render(r"\\[bold]FOO")
@ -165,7 +170,6 @@ def test_escape_escape():
def test_events():
result = render("[@click]Hello[/@click] [@click='view.toggle', 'left']World[/]")
assert str(result) == "Hello World"