simplify token replace, catch one-char end-of-string tokens
This commit is contained in:
parent
2218d4a888
commit
b2c5ad041c
1 changed files with 6 additions and 10 deletions
|
@ -129,12 +129,8 @@ def format_tokens(s: str, names: typing.List[str], sigil: str="$"
|
|||
|
||||
while i < max:
|
||||
if s[i] == sigil:
|
||||
if s[i+1] == sigil:
|
||||
if not s[i+1] == sigil:
|
||||
i += 1
|
||||
else:
|
||||
sigil_found = True
|
||||
elif sigil_found:
|
||||
sigil_found = False
|
||||
for name in names:
|
||||
if len(name) <= (len(s)-i) and s[i:i+len(name)] == name:
|
||||
tokens.append((i-1, "%s%s" % (sigil, name)))
|
||||
|
|
Loading…
Reference in a new issue