From 34a7ccfbbdcb3482ddebf5c6924e56dabb2a252e Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Mon, 25 Sep 2023 09:32:37 +0200 Subject: [PATCH] fix(colors): improve headings added(colors): caret lists --- main.js | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/main.js b/main.js index 5b2a62e..d53c7d8 100644 --- a/main.js +++ b/main.js @@ -2095,16 +2095,26 @@ function applycolors() lines.every( (line, i) => { line = escapeHtml(line); + + // headings if (line.startsWith("#")) { - line = line.replace(/(#*)/g, "$1"); - line = "" + line + ""; + line = line.replace(/(#* )/, "$1"); // to check! + line = "" + line + ""; } + + // lists if (line.startsWith("* ")) { line = line.replace(/(\* )/g, "$1"); } + else if (line.startsWith("- ")) + { + line = line.replace(/(\- )/g, "$1"); + } + // todo: use markerslist + // md header if (i == 0 && line == "---") { header = true; @@ -2118,9 +2128,11 @@ function applycolors() line = "" + line + ""; } - if (line == "```" && !code) + // code blocks + if (line.startsWith("```") && !code) { code = true; + //lg = line.substring(3); line = "
" + line; } if (line == "```" && code) @@ -2128,11 +2140,22 @@ function applycolors() code = false; line = line + "
"; } + /*else if (code) + { + line = line.replace(/(select)/ig, "$1"); + line = line.replace(/(from)/ig, "$1"); + line = line.replace(/(where)/ig, "$1"); + /// todo: keywords by language. whole word only. use a loop. etc. + }*/ + // internal links line = line.replace(/(\[\[.*\]\])/g, "$1"); + + // bold and italics line = line.replace(/(\*\*.*\*\*)/g, "$1"); line = line.replace(/(\*.*\*)/g, "$1"); + // comments line = line.replace(/<\!/g, "<!"); line = line.replace(/\-\->/g, "-->");