Add more colors to python.

This commit is contained in:
Tom Alexander 2025-02-22 18:26:33 -05:00
parent 04952895cf
commit c67eb32774
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
4 changed files with 50 additions and 12 deletions

17
TODO.org Normal file
View File

@ -0,0 +1,17 @@
* Things to do [3/14]
** DONE If the paragraph only contains an image, text-align center
** DONE Syntax highlighting for code blocks
** TODO Render gnuplot
** TODO Pretty-print the timestamps
** TODO Support Table of Contents
** TODO Support line numbers in code blocks
** TODO Support references to code block lines
** TODO Only include text up to first heading on homepage and include a "read more" link
** DONE Make loading language-specific CSS files conditional on the presence of src blocks using those languages
** TODO Set up tracing so I can use warning and such
** TODO Make copying of language-specific CSS files conditional on the presence of src blocks using those languages
** TODO Switch to an entirely lazily-evaluated output tree
** TODO Add highlighting for languages [0/2]
*** TODO bash
*** TODO gnuplot
** TODO Bug: carry over highlight starts when breaking lines

View File

@ -1,38 +1,50 @@
/* ea912c */
/* e95a62 */
:root { :root {
--srclg-python-srchl-keyword-color: #1a936f;
--srclg-python-srchl-comment-color: #048a81; --srclg-python-srchl-comment-color: #048a81;
--srclg-python-srchl-property-color: #bfbccb; --srclg-python-srchl-function-builtin-color: #e95a62;
--srclg-python-srchl-keyword-color: #1a936f;
--srclg-python-srchl-property-color: inherit;
--srclg-python-srchl-string-color: #ecc30b; --srclg-python-srchl-string-color: #ecc30b;
--srclg-python-srchl-string-special-path-color: #067bc2; --srclg-python-srchl-type-color: #067bc2;
--srclg-python-srchl-variable-color: #ea912c;
} }
@media (prefers-color-scheme: light) { @media (prefers-color-scheme: light) {
:root { :root {
--srclg-python-srchl-keyword-color: #e56c90;
--srclg-python-srchl-comment-color: #fb757e; --srclg-python-srchl-comment-color: #fb757e;
--srclg-python-srchl-property-color: #404334; --srclg-python-srchl-function-builtin-color: #16a59d;
--srclg-python-srchl-keyword-color: #e56c90;
--srclg-python-srchl-property-color: inherit;
--srclg-python-srchl-string-color: #133cf4; --srclg-python-srchl-string-color: #133cf4;
--srclg-python-srchl-string-special-path-color: #f9843d; --srclg-python-srchl-type-color: #f9843d;
--srclg-python-srchl-variable-color: #156ed3;
} }
} }
.main_content { .main_content {
.src_block { .src_block {
&.srclg_python { &.srclg_python {
.srchl_keyword {
color: var(--srclg-python-srchl-keyword-color);
}
.srchl_comment { .srchl_comment {
color: var(--srclg-python-srchl-comment-color); color: var(--srclg-python-srchl-comment-color);
} }
.srchl_function_builtin {
color: var(--srclg-python-srchl-function-builtin-color);
}
.srchl_keyword {
color: var(--srclg-python-srchl-keyword-color);
}
.srchl_property { .srchl_property {
color: var(--srclg-python-srchl-property-color); color: var(--srclg-python-srchl-property-color);
} }
.srchl_string { .srchl_string {
color: var(--srclg-python-srchl-string-color); color: var(--srclg-python-srchl-string-color);
} }
.srchl_string_special_path { .srchl_type {
color: var(--srclg-python-srchl-string-special-path-color); color: var(--srclg-python-srchl-type-color);
}
.srchl_variable {
color: var(--srclg-python-srchl-variable-color);
} }
} }
} }

View File

@ -161,6 +161,7 @@ body {
font-size: 1rem; font-size: 1rem;
font-family: var(--src-font-family); font-family: var(--src-font-family);
margin: 1rem 0; margin: 1rem 0;
font-variant-ligatures: none;
.src_language { .src_language {
display: inline-block; display: inline-block;

View File

@ -226,7 +226,15 @@ fn highlight_python<L>(lines: &[L]) -> Result<Vec<ISrcLine>, CustomError>
where where
L: Borrow<str>, L: Borrow<str>,
{ {
let highlight_names = ["comment"]; let highlight_names = [
"comment",
"function.builtin",
"keyword",
"property",
"string",
"type",
"variable",
];
let language = tree_sitter_python::LANGUAGE.into(); let language = tree_sitter_python::LANGUAGE.into();
let mut config = HighlightConfiguration::new( let mut config = HighlightConfiguration::new(
language, language,