fix format_token_replace for $$
This commit is contained in:
parent
c9a4656163
commit
5722a567a1
1 changed files with 2 additions and 2 deletions
|
@ -141,14 +141,14 @@ def format_tokens(s: str, names: typing.List[str], sigil: str="$"
|
||||||
i += len(name)
|
i += len(name)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
tokens.append((i, "$"))
|
tokens.append((i-1, "$$"))
|
||||||
i += 1
|
i += 1
|
||||||
return tokens
|
return tokens
|
||||||
|
|
||||||
def format_token_replace(s: str, vars: typing.Dict[str, str],
|
def format_token_replace(s: str, vars: typing.Dict[str, str],
|
||||||
sigil: str="$") -> str:
|
sigil: str="$") -> str:
|
||||||
vars = vars.copy()
|
vars = vars.copy()
|
||||||
vars.update({"": ""})
|
vars.update({sigil: sigil})
|
||||||
tokens = format_tokens(s, list(vars.keys()), sigil)
|
tokens = format_tokens(s, list(vars.keys()), sigil)
|
||||||
tokens.sort(key=lambda x: x[0])
|
tokens.sort(key=lambda x: x[0])
|
||||||
tokens.reverse()
|
tokens.reverse()
|
||||||
|
|
Loading…
Reference in a new issue