From 3e44416077267affa95a179c92303625d5ef0b9c Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Wed, 21 Oct 2020 22:30:38 +0300 Subject: [PATCH] Only consider single words as inline snippets Optionally surrounded by whitespace. This mirrors the restrictions on !!snippets. --- src/data/Thread.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/data/Thread.js b/src/data/Thread.js index 5b34a8b..75ebfc9 100644 --- a/src/data/Thread.js +++ b/src/data/Thread.js @@ -207,8 +207,9 @@ class Thread { }, {}); text = text.replace( - new RegExp(`${config.inlineSnippetStart}(.+?)${config.inlineSnippetEnd}`, "i"), + new RegExp(`${config.inlineSnippetStart}(\\s*\\S+?\\s*)${config.inlineSnippetEnd}`, "i"), (orig, trigger) => { + trigger = trigger.trim(); const snippet = snippetMap[trigger.toLowerCase()]; return snippet != null ? snippet.body : orig; }