russell.ballestrini.net/Makefile
Russell Ballestrini 05c9f19913 Make pygments generation part of build process
html target now depends on pygments target, ensuring stylesheets are
always generated and patched before building the site
2025-10-13 11:57:31 -04:00

60 lines
2.8 KiB
Makefile

.PHONY: html help clean regenerate serve devserver publish pygments
BASEDIR=$(CURDIR)
INPUTDIR=$(BASEDIR)/content
OUTPUTDIR=$(BASEDIR)/output
CONFFILE=$(BASEDIR)/pelicanconf.py
PUBLISHCONF=$(BASEDIR)/publishconf.py
help:
@echo 'Makefile for a pelican Web site '
@echo ' '
@echo 'Usage: '
@echo ' make venv setup virtual environment '
@echo ' make resume (re)generate the resume '
@echo ' make html (re)generate the web site '
@echo ' make clean remove the generated files '
@echo ' make regenerate regenerate files upon modification '
@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
venv:
python3 -m venv venv
venv/bin/pip install -r requirements.txt
mkdir -p pelican-themes
cd pelican-themes && git clone $(THEME_REPO_URL)
venv/bin/pelican-themes -i pelican-themes/pelican-svbhack/
resume:
venv/bin/rst2pdf content/pages/russell.ballestrini.resume.rst --stylesheets content/pages/russell.ballestrini.resume.style -o output/uploads/russell.ballestrini.resume.pdf
html: pygments
venv/bin/pelican content -o output -s pelicanconf.py
clean:
[ ! -d output ] || rm -rf output
regenerate:
venv/bin/pelican -r content -o output -s pelicanconf.py
serve:
venv/bin/pelican -l content -o output -s pelicanconf.py
devserver:
venv/bin/pelican -lr content -o output -s pelicanconf.py
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."