One function

escape in Textualize/rich

The author described this change as fix escaping issue. It counts as a record because the check below fails on the code as it stood at e3fdf3304 and passes on 193903dff, with nothing else changed between the two runs.

Fix saved2022-04-12
Sharing licenceMIT · LICENSE
Change size+2 1

What the code was meant to do, written into the code itself as a docstring

Escapes text so that it won't be interpreted as markup. Args: markup (str): Content to be inserted in to markup. Returns: str: Markup with square brackets escaped.

The change

11 def escape(
2- markup: str, _escape: _EscapeSubMethod = re.compile(r"(\\*)(\[[a-z#\/@].*?\])").sub
2+ markup: str,
3+ _escape: _EscapeSubMethod = re.compile(r"(\\*)(\[[a-z#/@][^[]*?])").sub,
34 ) -> str:
45 """Escapes text so that it won't be interpreted as markup.
56

The check that tells the two apart

failpass·tests/test_markup.py::test_escape

Check file tests/test_markup.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before ite3fdf3304341e8930ad913be6c67b40ef0e64457
Broken version dated2022-04-06
Modulerich.markup
Units changedescape
Fingerprint1e381f311d67022c
Checked2026-08-17 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in Textualize/rich