manual/luadoc: added dark theme support
using media query: prefers-color-scheme = dark
Dieser Commit ist enthalten in:
Ursprung
7ded888173
Commit
f383ed1a5d
@ -737,19 +737,19 @@ class LuaDoc:
|
||||
if len(index[letter]) != 0:
|
||||
html += ' <li><a href="#' + letter + '">' + letter + '</a></li>' + os.linesep
|
||||
else:
|
||||
html += ' <li style="color:#888;">' + letter + '</li>' + os.linesep
|
||||
html += ' <li class="dim">' + letter + '</li>' + os.linesep
|
||||
|
||||
html += '</ul>' + os.linesep
|
||||
html += '<div class="index-az">' + os.linesep
|
||||
for letter in alphabet:
|
||||
html += '<h4 id="' + letter + '"'
|
||||
if len(index[letter]) == 0:
|
||||
html += ' style="color:#888;"'
|
||||
html += ' class="dim"'
|
||||
html += '>' + letter + '</h4>' + os.linesep
|
||||
if len(index[letter]) != 0:
|
||||
html += '<ul>' + os.linesep
|
||||
for item in sorted(index[letter], key=operator.itemgetter('title', 'sub_title')):
|
||||
html += ' <li><a href="' + item['href'] + '">' + item['title'] + '</a> <small style="color:#444;">' + item['sub_title'] + '</small></li>' + os.linesep
|
||||
html += ' <li><a href="' + item['href'] + '">' + item['title'] + '</a> <small class="dim">' + item['sub_title'] + '</small></li>' + os.linesep
|
||||
html += '</ul>' + os.linesep
|
||||
html += '</div>' + os.linesep
|
||||
LuaDoc._write_file(os.path.join(output_dir, LuaDoc.FILENAME_INDEX_AZ), html)
|
||||
|
||||
@ -310,7 +310,7 @@ pre[lang="lua"]
|
||||
background-color: #f8f8f8;
|
||||
font-size: 80%;
|
||||
line-height: normal;
|
||||
padding: 0.2em 0.3em 0.2em 0.3em;
|
||||
padding: 0.4em;
|
||||
}
|
||||
|
||||
pre[lang="lua"] code span.const
|
||||
@ -335,12 +335,12 @@ pre[lang="lua"] code span.text
|
||||
|
||||
pre[lang="lua"] code span.comment
|
||||
{
|
||||
color: darkslategray;
|
||||
color: gray;
|
||||
}
|
||||
|
||||
code.lua span.keyword
|
||||
pre[lang="lua"] code span.function
|
||||
{
|
||||
color: #000080;
|
||||
color: teal;
|
||||
}
|
||||
|
||||
/** MEDIA BREAKPOINTS ********************************************************/
|
||||
@ -357,3 +357,77 @@ code.lua span.keyword
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
/** Dark mode **/
|
||||
|
||||
@media (prefers-color-scheme: dark)
|
||||
{
|
||||
body
|
||||
{
|
||||
background-color: #111;
|
||||
color: #eee;
|
||||
}
|
||||
|
||||
a
|
||||
{
|
||||
color: rgb(47, 129, 247)
|
||||
}
|
||||
|
||||
#toc
|
||||
{
|
||||
border-color: #555;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
#toc a:hover,
|
||||
#toc a.selected
|
||||
{
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.content table thead tr
|
||||
{
|
||||
background: #222;
|
||||
}
|
||||
|
||||
.content table tbody tr:nth-child(even)
|
||||
{
|
||||
background: #222;
|
||||
}
|
||||
|
||||
p.note
|
||||
{
|
||||
border-left-color: blue;
|
||||
}
|
||||
|
||||
pre[lang="lua"]
|
||||
{
|
||||
border-color: gray;
|
||||
background-color: #222;
|
||||
}
|
||||
|
||||
pre[lang="lua"] code span.const
|
||||
{
|
||||
color: violet;
|
||||
}
|
||||
|
||||
pre[lang="lua"] code span.text
|
||||
{
|
||||
color: lawngreen;
|
||||
}
|
||||
|
||||
pre[lang="lua"] code span.keyword
|
||||
{
|
||||
color: cyan;
|
||||
}
|
||||
|
||||
pre[lang="lua"] code span.global
|
||||
{
|
||||
color: orange;
|
||||
}
|
||||
|
||||
pre[lang="lua"] code span.function
|
||||
{
|
||||
color: #66CDAA;
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,6 +25,7 @@ def highlight_lua(code: str) -> str:
|
||||
code = re.sub(r'\b(math|table|string|class|enum|set|log|world)\b', r'<span class="global">\1</span>', code) # globals
|
||||
code = re.sub(r'\b([A-Z_][A-Z0-9_]*)\b', r'<span class="const">\1</span>', code) # CONSTANTS
|
||||
code = re.sub(r'\b(and|break|do|else|elseif|end|false|for|function|goto|if|in|local|nil|not|or|repeat|return|then|true|until|while)\b', r'<span class="keyword">\1</span>', code) # keywords
|
||||
code = re.sub(r'\b([a-zA-Z_][a-zA-Z0-9_]*)(?=\()', r'<span class="function">\1</span>', code) # functions
|
||||
code = re.sub(r'(\a.*?[^\\]\a|\a\a)', lambda m: highlight_replace(m.group(1), 'text'), code)
|
||||
code = re.sub(r"('.*?[^\\]'|'')", lambda m: highlight_replace(m.group(1), 'text'), code)
|
||||
code = re.sub(r'(--.*)$', lambda m: highlight_replace(m.group(1), 'comment'), code, flags=re.MULTILINE) # single line comments
|
||||
|
||||
Laden…
x
In neuem Issue referenzieren
Einen Benutzer sperren