« get me outta code hell

match hash/replacerValue only without preceding WS - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <towerofnix@gmail.com>2021-04-16 13:54:55 -0300
committer(quasar) nebula <towerofnix@gmail.com>2021-04-16 13:54:55 -0300
commit094e5a621b80b21bbc03937e2b40e1c32df93315 (patch)
tree0152c31dc7a3f3aacd72b8bdf0b4c5f42baa4a5a
parentd1e808ee9585786a28a73b66ed1b20a58b63b80a (diff)
match hash/replacerValue only without preceding WS
-rwxr-xr-xupd8.js31
1 files changed, 24 insertions, 7 deletions
diff --git a/upd8.js b/upd8.js
index 17811076..d2983e7e 100755
--- a/upd8.js
+++ b/upd8.js
@@ -970,13 +970,30 @@ const replacerSpec = {
     const tagArgumentValue = '=';
     const tagLabel = '|';
 
-    const R_tagBeginning = escapeRegex(tagBeginning);
-    const R_tagEnding = escapeRegex(tagEnding);
-    const R_tagReplacerValue = escapeRegex(tagReplacerValue);
-    const R_tagHash = escapeRegex(tagHash);
-    const R_tagArgument = escapeRegex(tagArgument);
-    const R_tagArgumentValue = escapeRegex(tagArgumentValue);
-    const R_tagLabel = escapeRegex(tagLabel);
+    const noPrecedingWhitespace = '(?<!\\s)';
+
+    const R_tagBeginning =
+        escapeRegex(tagBeginning);
+
+    const R_tagEnding =
+        escapeRegex(tagEnding);
+
+    const R_tagReplacerValue =
+        noPrecedingWhitespace +
+        escapeRegex(tagReplacerValue);
+
+    const R_tagHash =
+        noPrecedingWhitespace +
+        escapeRegex(tagHash);
+
+    const R_tagArgument =
+        escapeRegex(tagArgument);
+
+    const R_tagArgumentValue =
+        escapeRegex(tagArgumentValue);
+
+    const R_tagLabel =
+        escapeRegex(tagLabel);
 
     const regexpCache = {};