From 8bde2cfbffdc5155ee583c7e26a7699c661dd3c3 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Mon, 16 Feb 2026 18:18:44 -0600 Subject: [PATCH] allow non-standerd spaces --- src/webpage/markdown.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/webpage/markdown.ts b/src/webpage/markdown.ts index b8ccaf4..84cef24 100644 --- a/src/webpage/markdown.ts +++ b/src/webpage/markdown.ts @@ -126,6 +126,7 @@ class MarkDown { return Array.from(span.childNodes).at(-1); } for (let i = 0; i < txt.length; i++) { + const isSpace = /^\s$/; if (txt[i] === "\n" || i === 0) { let first = i === 0; if (first) { @@ -136,22 +137,22 @@ class MarkDown { if (txt[i + 1] === "#") { if (txt[i + 2] === "#") { - if (txt[i + 3] === "#" && txt[i + 4] === " ") { + if (txt[i + 3] === "#" && txt[i + 4]?.match(isSpace)) { element = document.createElement("h3"); keepys = "### "; i += 5; - } else if (txt[i + 3] === " ") { + } else if (txt[i + 3]?.match(isSpace)) { element = document.createElement("h2"); element.classList.add("h2md"); keepys = "## "; i += 4; } - } else if (txt[i + 2] === " ") { + } else if (txt[i + 2]?.match(isSpace)) { element = document.createElement("h1"); keepys = "# "; i += 3; } - } else if (txt[i + 1] === ">" && txt[i + 2] === " ") { + } else if (txt[i + 1] === ">" && txt[i + 2]?.match(isSpace)) { element = document.createElement("div"); const line = document.createElement("div"); line.classList.add("quoteline");