fix format_token_replace for $$

This commit is contained in:
jesopo 2020-01-25 11:32:01 +00:00
parent c9a4656163
commit 5722a567a1

View file

@ -141,14 +141,14 @@ def format_tokens(s: str, names: typing.List[str], sigil: str="$"
i += len(name)
break
else:
tokens.append((i, "$"))
tokens.append((i-1, "$$"))
i += 1
return tokens
def format_token_replace(s: str, vars: typing.Dict[str, str],
sigil: str="$") -> str:
vars = vars.copy()
vars.update({"": ""})
vars.update({sigil: sigil})
tokens = format_tokens(s, list(vars.keys()), sigil)
tokens.sort(key=lambda x: x[0])
tokens.reverse()