diff --git a/core/snippets/snippets_insert.py b/core/snippets/snippets_insert.py index 343b45327f..8d23726891 100644 --- a/core/snippets/snippets_insert.py +++ b/core/snippets/snippets_insert.py @@ -72,6 +72,7 @@ def compute_snippet_body_with_substitutions( body = snippet.body if substitutions: for k, v in substitutions.items(): + v = v.replace("$", r"\$") reg = re.compile(rf"\${k}|\$\{{{k}\}}") if not reg.search(body): raise ValueError( diff --git a/core/snippets/snippets_insert_raw_text.py b/core/snippets/snippets_insert_raw_text.py index b51484cf8a..b8dff28ba9 100644 --- a/core/snippets/snippets_insert_raw_text.py +++ b/core/snippets/snippets_insert_raw_text.py @@ -164,7 +164,7 @@ def format_tabs(text: str) -> str: spaces_per_tab: int = settings.get("user.snippet_raw_text_spaces_per_tab") if spaces_per_tab < 0: return text - return re.sub(r"\t", " " * spaces_per_tab, text) + return text.replace("\t", " " * spaces_per_tab) def parse_snippet(body: str):