From 56aa5e937408f6fd2ae193813db5e146b625d9ff Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sat, 16 Sep 2023 13:26:12 -0400 Subject: [PATCH] escape stars in readme as well --- bin/update-playlist | 2 +- tests/update_playlist_test.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/update-playlist b/bin/update-playlist index 0e48084d..0b6a2375 100755 --- a/bin/update-playlist +++ b/bin/update-playlist @@ -6,7 +6,7 @@ import re import json REMOVE_NUMBERS = re.compile('(?: --)? #[0-9]+$') -ESCAPE = {ord('\\'): r'\\', ord('_'): r'\_', ord('['): r'\[', ord(']'): r'\]'} +ESCAPE = {ord(c): fr'\{c}' for c in r'\_[]*'} def _escape(s: str) -> str: diff --git a/tests/update_playlist_test.py b/tests/update_playlist_test.py index a4f2bf95..2e48afe8 100644 --- a/tests/update_playlist_test.py +++ b/tests/update_playlist_test.py @@ -22,6 +22,11 @@ 'something `__main__` `[]` (intermediate)', id='leave special characters alone inside backticks', ), + pytest.param( + 'python **ZERO**', + r'python \*\*ZERO\*\*', + id='escape stars as well!', + ), ), ) def test_escape(s, expected):