Revert "ongoing refactor to update colors by line"
This reverts commit cbac831768
.
This commit is contained in:
parent
24046d9f23
commit
fa2afdeab5
44
main.js
44
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(/(#* )/, "<span style='color:" + settings.accentcolor + "'>$1</span>"); // to check!
|
||||
line = "<span style='font-weight: bold;'>" + line + "</span>";
|
||||
}
|
||||
|
||||
// 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
|
||||
|
|
Loading…
Reference in New Issue