Skip to content

Commit

Permalink
Merge pull request #379 from anthonywritescode/escape-stars
Browse files Browse the repository at this point in the history
escape stars in readme as well
  • Loading branch information
asottile authored Sep 16, 2023
2 parents 5667d7e + 56aa5e9 commit 281660c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bin/update-playlist
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions tests/update_playlist_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 281660c

Please sign in to comment.