Add make pygments target to generate and patch syntax highlighting stylesheets

Generates monokai (dark) and default (light) pygments styles and automatically
patches dark mode to remove hardcoded background color
This commit is contained in:
Russell Ballestrini 2025-10-13 11:56:13 -04:00
parent 1f310836ff
commit 58ace94933

View file

@ -1,4 +1,4 @@
.PHONY: html help clean regenerate serve devserver publish
.PHONY: html help clean regenerate serve devserver publish pygments
BASEDIR=$(CURDIR)
INPUTDIR=$(BASEDIR)/content
@ -18,6 +18,7 @@ help:
@echo ' make publish generate using production settings '
@echo ' make serve serve site at http://localhost:8000'
@echo ' make devserver serve and regenerate together '
@echo ' make pygments generate pygments stylesheets '
@echo ' '
THEME_REPO_URL ?= git@github.com:russellballestrini/pelican-svbhack.git
@ -49,3 +50,11 @@ devserver:
publish:
venv/bin/pelican content -o output -s publishconf.py
pygments:
@echo "Generating pygments stylesheets..."
venv/bin/python -c "from pygments.formatters import HtmlFormatter; print(HtmlFormatter(style='monokai').get_style_defs('.highlight'))" > pelican-themes/pelican-svbhack/static/css/pygments-dark.css
venv/bin/python -c "from pygments.formatters import HtmlFormatter; print(HtmlFormatter(style='default').get_style_defs('.highlight'))" > pelican-themes/pelican-svbhack/static/css/pygments-light.css
@echo "Patching dark mode to remove hardcoded background..."
sed -i 's/.highlight { background: #272822; color: #f8f8f2 }/.highlight { color: #f8f8f2 }/' pelican-themes/pelican-svbhack/static/css/pygments-dark.css
@echo "Done! Pygments stylesheets generated and patched."