diff --git a/main.js b/main.js
index 082e36a..df39a3a 100644
--- a/main.js
+++ b/main.js
@@ -1966,46 +1966,17 @@ function rawline(index)
return md.value.split("\n")[index];
}
-function applycolorsonline(line, linediv, index, options)
+function applycolorsonline(line, index, options)
{
line = escapeHtml(line);
- while (linediv.hasChildNodes())
- {
- linediv.removeChild(linediv.lastChild);
- }
-
// headings
if (line.startsWith("#"))
{
- var level = line.indexOf(" ");
- if (level == -1)
- {
- level = line.length;
- }
-
- var span = document.createElement("span");
- span.setAttribute("style", `font-weight: bold;color:${settings.accentcolor};`);
- span.appendChild(document.createTextNode("#".repeat(level)));
- linediv.appendChild(span);
-
- if (level < line.length)
- {
- var headingtext = line.substring(level);
- span = document.createElement("span");
- span.setAttribute("style", "font-weight: bold;");
- span.appendChild(document.createTextNode(headingtext));
- linediv.appendChild(span);
- }
- return;
+ line = line.replace(/(#* )/, "$1"); // to check!
+ line = "" + line + "";
}
- // fallback
- //linediv.appendChild(document.createTextNode(line || " "));
- //return;
-
- /* -----TODO------ */
-
// bold and italics
var temp = line;
if (line.startsWith("* "))
@@ -2129,8 +2100,7 @@ function applycolorsonline(line, linediv, index, options)
}
}
}
-
- linediv.innerHTML = line || " ";
+ return line;
}
function applycolors(currentonly)
@@ -2153,7 +2123,9 @@ function applycolors(currentonly)
var index = currentline();
var linediv = document.getElementById("line" + index);
options = JSON.parse(linediv.getAttribute("tag"));
- applycolorsonline(rawline(index), linediv, index, options);
+ var line = rawline(index);
+ line = applycolorsonline(line, index, options);
+ linediv.innerHTML = line || " ";
}
else
{
@@ -2170,7 +2142,7 @@ function applycolors(currentonly)
}
linediv.setAttribute("id", "line" + i);
linediv.setAttribute("tag", JSON.stringify(options));
- applycolorsonline(lines[i], linediv, i, options);
+ linediv.innerHTML = applycolorsonline(lines[i], i, options) || " ";
};
// remove remanining