« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/util/replacer.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/util/replacer.js b/src/util/replacer.js
index c1d13c7c..9544328f 100644
--- a/src/util/replacer.js
+++ b/src/util/replacer.js
@@ -201,6 +201,8 @@ function parseNodes(input, i, stopAt, textOnly) {
       string = string.trimEnd();
     }
 
+    string = squashBackslashes(string);
+
     if (string.length) {
       nodes.push({i: iString, iEnd: i, type: 'text', data: string});
       string = '';
@@ -418,6 +420,15 @@ function parseNodes(input, i, stopAt, textOnly) {
   return nodes;
 }
 
+export function squashBackslashes(text) {
+  // Squash backslashes which aren't themselves escaped into
+  // the following character, unless that character is one of
+  // a set of characters where the backslash carries meaning
+  // into later formatting (i.e. markdown). Note that we do
+  // NOT compress double backslashes into single backslashes.
+  return text.replace(/([^\\](?:\\{2})*)\\(?![\\*_-])/g, '$1');
+}
+
 export function postprocessImages(inputNodes) {
   const outputNodes = [];