refactor(colors) and add setting to set dark background to block code

This commit is contained in:
quenousimporte 2023-11-10 17:17:09 +01:00
parent 5ba803f0a6
commit f4349d1ae6
2 changed files with 20 additions and 4 deletions

18
main.js
View File

@ -19,7 +19,8 @@ var defaultsettings =
password: "",
sync: false,
tagsinlists: true,
tagfilter: ""
tagfilter: "",
darkcode: true
};
//builtin
@ -2013,17 +2014,26 @@ function rawline2html(line, index, options)
{
options.code = true;
options.language = line.substring(3);
line = "<div style='color:white;background-color:black;'>" + line.replace(new RegExp("(" + options.language + ")"), "<span style='text-shadow: " + shadow + ";color:" + settings.accentcolor + ";'>$1</span>") + "</div>";
if (settings.darkcode)
{
line = "<div class='color-code'>" + line.replace(new RegExp("(" + options.language + ")"), "<span style='text-shadow: " + shadow + ";color:" + settings.accentcolor + ";'>$1</span>") + "</div>";
}
}
else if (line == "```" && options.code)
{
options.code = false;
options.language = "";
line = "<div style='color:white;background-color:black;'>" + line + "</div>";
if (settings.darkcode)
{
line = "<div class='color-code'>" + line + "</div>";
}
}
else if (options.code)
{
line = "<div style='color:white;background-color:black;'>" + (line || emptyline) + "</div>";
if (settings.darkcode)
{
line = "<div class='color-code'>" + (line || emptyline) + "</div>";
}
if (languagekeywords[options.language])
{
var keywords = languagekeywords[options.language];

View File

@ -136,4 +136,10 @@ body::-webkit-scrollbar-thumb {
cursor: pointer;
background-color: darkgray;
margin: 2px 2px 2px 2px;
}
/* colors */
.color-code {
color:white;
background-color:black;
}