refactor: list markers

This commit is contained in:
quenousimporte 2023-10-19 13:50:30 +02:00
parent 17a34a081a
commit 1b0d25a982
1 changed files with 20 additions and 12 deletions

32
main.js
View File

@ -1997,12 +1997,27 @@ function applycolorsonline(line, linediv, index, options)
span.appendChild(document.createTextNode(headingtext));
linediv.appendChild(span);
}
return;
}
else if (markerslist.every(marker =>
{
if (line.startsWith(marker))
{
var span = document.createElement("span");
span.setAttribute("style", `color:${settings.accentcolor};`);
span.appendChild(document.createTextNode(marker.replaceAll("*", settings.bulletrendering)));
linediv.appendChild(span);
linediv.appendChild(document.createTextNode(line.substring(marker.length)));
return false;
}
return true;
}))
{
// fallback
linediv.appendChild(document.createTextNode(line || " "));
}
// fallback
//linediv.appendChild(document.createTextNode(line || " "));
//return;
return;
/* -----TODO------ */
@ -2024,14 +2039,7 @@ function applycolorsonline(line, linediv, index, options)
line = temp;
}
// lists
markerslist.forEach(marker =>
{
if (line.startsWith(marker))
{
line = line.replace(marker, "<span style='color:" + settings.accentcolor + "'>" + marker.replaceAll("*", settings.bulletrendering) + "</span>");
}
});
// md header
if (index == 0 && line == "---")