diff --git a/js/interactivity.js b/js/interactivity.js index fcf32e3..3bd51f4 100644 --- a/js/interactivity.js +++ b/js/interactivity.js @@ -292,7 +292,7 @@ window.WAM = window.WAM || {}; return String(s == null ? "" : s) .replace(/```([\s\S]*?)```/g, "$1") .replace(/`([^`\n]+)`/g, "$1") - .replace(reMarca("\*"), "$1$2") + .replace(reMarca("*"), "$1$2") .replace(reMarca("_"), "$1$2") .replace(reMarca("~"), "$1$2") .trim(); @@ -300,13 +300,10 @@ window.WAM = window.WAM || {}; /* Misma regla que render.js: marca pegada a un carácter no blanco por dentro y sin letra, número ni _ por fuera («2 * 3 * 4» queda literal). */ - function reMarca(e) { - try { - return new RegExp("(^|[^\p{L}\p{N}_" + e + "])" + e + "(?=\S)([^" + e + "\n]*?\S)" + e + - "(?=[^\p{L}\p{N}_" + e + "]|$)", "gu"); - } catch (err) { - return new RegExp("(^|[^\w" + e + "])" + e + "(?=\S)([^" + e + "\n]*?\S)" + e + "(?=[^\w" + e + "]|$)", "g"); - } + function reMarca(m) { + var e = m === "*" ? "\\*" : m; /* con flag u, "\_" y "\~" son escapes inválidos */ + return new RegExp("(^|[^\\p{L}\\p{N}_" + e + "])" + e + "(?=\\S)([^" + e + "\\n]*?\\S)" + e + + "(?=[^\\p{L}\\p{N}_" + e + "]|$)", "gu"); } function miniaturaSegura(u) {