⚙️ Improving Syntax Highlighting
One minor flaw in the otherwise awesome Bearming theme is that its code highlighting palette is hard to read against the code block background colors- particularly in dark mode. It's not like I have any code posts at the moment, but I definitely want to get that right in my own variation of the theme. I looked into it a little bit, but didn't realize that Pygments was the library used by Bear Blog.
Recently I noticed that Sylvia had clearly solved the issue with her blog's theme, but it was only today that I thought to look in her archive and see if she had documented her syntax highlighting solution. Sure enough, she had, and it's actually a fair amount of work because Pygments has a ton of classes to cover so many possible elements.
Here's my lazy first pass based on the Monokai theme that looks pretty good in the dark mode of my site (which is how I normally view things). I'd like to redo the stylesheet with variables at some point so I can further refine it for light mode, but I think it's fine for the moment.
from typing import Iterator
# This is an example
class Math:
@staticmethod
def fib(n: int) -> Iterator[int]:
"""Fibonacci series up to n."""
a, b = 0, 1
while a < n:
yield a
a, b = b, a + b
result = sum(Math.fib(42))
print(f"The answer is {result}")