« get me outta code hell

move textOnly tag test before advancing past "[[" - 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-19 11:59:47 -0300
committer(quasar) nebula <towerofnix@gmail.com>2021-04-19 11:59:47 -0300
commite7bff2495c2ce2b7c1dd01061616bf9e067f469c (patch)
tree3c55566574efe92237d8f80e5d21739367ff128a
parent40f6c3b14aacdb96e1b20b4c2e3e1365ccd372c4 (diff)
move textOnly tag test before advancing past "[["
This makes syntax error messages a little nicer, i.e.

    hello there [[album:[[lol]]]]
    --------------------^

instead of

    hello there [[album:[[lol]]]]
    ----------------------^
-rwxr-xr-xupd8.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/upd8.js b/upd8.js
index de6af973..e425cb77 100755
--- a/upd8.js
+++ b/upd8.js
@@ -1066,6 +1066,9 @@ const replacerSpec = {
             i = closestMatchIndex;
             pushTextNode();
 
+            if (textOnly && closestMatch === tagBeginning)
+                throw makeError(i, `Unexpected [[tag]] - expected only text here.`);
+
             i += closestMatch.length;
 
             if (closestMatch !== tagBeginning) {
@@ -1077,9 +1080,6 @@ const replacerSpec = {
             }
 
             if (closestMatch === tagBeginning) {
-                if (textOnly)
-                    throw makeError(i, `Unexpected [[tag]] - expected only text here.`);
-
                 const iTag = closestMatchIndex;
 
                 let N;