aboutsummaryrefslogtreecommitdiff
path: root/src/utils/parse
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/parse')
-rw-r--r--src/utils/parse/__init__.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/utils/parse/__init__.py b/src/utils/parse/__init__.py
index 4fd75e04..28f074c2 100644
--- a/src/utils/parse/__init__.py
+++ b/src/utils/parse/__init__.py
@@ -134,9 +134,12 @@ def format_token_replace(s: str, vars: typing.Dict[str, str],
sigil: str="$") -> str:
vars = vars.copy()
vars.update({sigil: sigil})
+
tokens = format_tokens(s, sigil)
+ # reverse sort tokens so replaces don't effect proceeding indexes
tokens.sort(key=lambda x: x[0])
tokens.reverse()
+
for start, end, token in tokens:
if token in vars:
s = s[:start] + vars[token] + s[end+1:]