« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/upd8.js
diff options
context:
space:
mode:
Diffstat (limited to 'upd8.js')
-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 = {};