From 5f0bdaf49ec123389bb828379c04af46775c64e5 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 26 Dec 2023 16:31:05 +0300 Subject: [PATCH 1/3] Add build rules for WeasyPrint examples --- Makefile | 24 +++++++++++++++--------- flake.nix | 1 + 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index bb9dfbe..5d981f3 100644 --- a/Makefile +++ b/Makefile @@ -14,13 +14,16 @@ SILE ?= sile TERA ?= tera TOMLQ ?= tomlq TYPST ?= typst +WEASYPRINT ?= weasyprint XELATEX ?= xelatex XQ ?= xq ZOLA ?= zola -TYPESETTERS = xelatex typst sile +TYPESETTERS = sile typst weasyprint xelatex BASE_URL = / +WEASYPRINT_ARGS = $< $@ + XELATEX_ARGS = -interaction=batchmode -halt-on-error XELATEX_ARGS += -jobname $*-xelatex $< @@ -53,25 +56,28 @@ all: $(PDFS) node_modules: $(NPM) ci -%-xelatex.pdf %-xelatex.toml: %/xelatex.tex - $(call make_manifest,$(XELATEX) $(XELATEX_ARGS)) - -%-typst.pdf %-typst.toml: %/typst.typ - $(call make_manifest,$(TYPST) $(TYPST_ARGS)) - %-sile.pdf %-sile.toml: %/sile.sil $(call make_manifest,$(SILE) $(SILE_ARGS)) %-sile.pdf %-sile.toml: %/sile.xml $(call make_manifest,$(SILE) $(SILE_ARGS)) -%.avif: %.pdf - $(MAGICK) convert $< $@ +%-typst.pdf %-typst.toml: %/typst.typ + $(call make_manifest,$(TYPST) $(TYPST_ARGS)) + +%-weasyprint.pdf %-weasyprint.html: %/weasyprint.html + $(call make_manifest,$(WEASYPRINT) $(WEASYPRINT_ARGS)) + +%-xelatex.pdf %-xelatex.toml: %/xelatex.tex + $(call make_manifest,$(XELATEX) $(XELATEX_ARGS)) static/%.css: sass/%.scss | node_modules $(NPX) sass --no-source-map $<:$@ $(NPX) postcss -u autoprefixer --no-map $@ -o $@ +%.avif: %.pdf + $(MAGICK) convert $< $@ + .PHONY: static static: $(PDFS) $(PREVIEWS) static/main.css install -Dm0644 -t static $(filter-out static/%,$^) diff --git a/flake.nix b/flake.nix index dee77c0..751a254 100644 --- a/flake.nix +++ b/flake.nix @@ -49,6 +49,7 @@ teracli.defaultPackage.${system} texlive.combined.scheme-full typst + weasyprint yq zola zsh From be749189654c73c966f8ea0a82c72d0f586783ad Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 26 Dec 2023 16:35:25 +0300 Subject: [PATCH 2/3] Add hello-world example using WeasyPrint --- content/hello-world.md | 2 +- data/hello-world/weasyprint.html | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 data/hello-world/weasyprint.html diff --git a/content/hello-world.md b/content/hello-world.md index 51de810..a73f63f 100644 --- a/content/hello-world.md +++ b/content/hello-world.md @@ -1,7 +1,7 @@ +++ title = "Hello World!" description = "Your most basic greeting." -extra.typesetters = [ "typst", "sile", "xelatex" ] +extra.typesetters = [ "sile", "typst", "weasyprint", "xelatex" ] +++ Just the simplest way to get a phrase onto a numbered page. diff --git a/data/hello-world/weasyprint.html b/data/hello-world/weasyprint.html new file mode 100644 index 0000000..0de7162 --- /dev/null +++ b/data/hello-world/weasyprint.html @@ -0,0 +1,13 @@ + + + +

Hello World

+ From d275259a2a4aecb8eee193bab13c4a32ecebd547 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 26 Dec 2023 17:32:43 +0300 Subject: [PATCH 3/3] Limit build attempts to tagged typesetters --- Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 5d981f3..9d00602 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,7 @@ GIT ?= git MAGICK ?= magick NPM ?= npm NPX ?= npx +SED ?= sed SILE ?= sile TERA ?= tera TOMLQ ?= tomlq @@ -34,9 +35,11 @@ SILE_ARGS = -o $@ $< .PHONY: default default: public +get_typesetters = $(shell $(SED) '0,/^\+\+\+$$/d;/^\+\+\+$$/,$$d' $1 | $(TOMLQ) -r '.extra.typesetters[]' | xargs) + SAMPLES := $(notdir $(shell echo data/*(/))) -MANIFESTS := $(foreach S,$(SAMPLES),$(foreach T,$(TYPESETTERS),data/$(S)-$(T).toml)) -PDFS := $(foreach S,$(SAMPLES),$(foreach T,$(TYPESETTERS),data/$(S)-$(T).pdf)) +MANIFESTS := $(foreach S,$(SAMPLES),$(foreach T,$(call get_typesetters,content/$(S).md),data/$(S)-$(T).toml)) +PDFS := $(addsuffix .pdf,$(basename $(MANIFESTS))) PREVIEWS := $(addsuffix .avif,$(basename $(PDFS))) define make_manifest ?=