« get me outta code hell

replacer: never process "<html:a>", restore "<a>" into text nodes - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/util
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-02-29 14:15:11 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-02-29 14:15:11 -0400
commit5154ff908db6ca5dfeb2dd0587f83846bbde2500 (patch)
tree32ee9784bcf87810b0e00eb2c9ecf7e42203bbe3 /src/util
parent79d4babd1e1132cbc26d92713690b290d1a5133a (diff)
replacer: never process "<html:a>", restore "<a>" into text nodes
Diffstat (limited to 'src/util')
-rw-r--r--src/util/replacer.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/util/replacer.js b/src/util/replacer.js
index 2c0e89f1..f692b068 100644
--- a/src/util/replacer.js
+++ b/src/util/replacer.js
@@ -201,7 +201,7 @@ function parseNodes(input, i, stopAt, textOnly) {
       string = string.trimEnd();
     }
 
-    string = squashBackslashes(string);
+    string = cleanRawText(string);
 
     if (string.length) {
       nodes.push({i: iString, iEnd: i, type: 'text', data: string});
@@ -429,6 +429,19 @@ export function squashBackslashes(text) {
   return text.replace(/([^\\](?:\\{2})*)\\(?![\\*_-])/g, '$1');
 }
 
+export function restoreRawHTMLTags(text) {
+  // Replace stuff like <html:a> with <a>; these signal that
+  // the tag shouldn't be processed by the replacer system,
+  // and should just be embedded into the content as raw HTML.
+  return text.replace(/<html:(.*?)(?=[ >])/g, '<$1');
+}
+
+export function cleanRawText(text) {
+  text = squashBackslashes(text);
+  text = restoreRawHTMLTags(text);
+  return text;
+}
+
 export function postprocessImages(inputNodes) {
   const outputNodes = [];