Skip to content

Commit

Permalink
Merge branch 'weasyprint'
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Dec 26, 2023
2 parents fcb0e39 + d275259 commit 85740d6
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 12 deletions.
31 changes: 20 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@ GIT ?= git
MAGICK ?= magick
NPM ?= npm
NPX ?= npx
SED ?= sed
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 $<

Expand All @@ -31,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 ?=
Expand All @@ -53,25 +59,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/%,$^)
Expand Down
2 changes: 1 addition & 1 deletion content/hello-world.md
Original file line number Diff line number Diff line change
@@ -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.
13 changes: 13 additions & 0 deletions data/hello-world/weasyprint.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<html>
<head>
<style>
@page {
@bottom-center {
content: counter(page);
position: absolute;
z-index: -1;
}
}
</style>
<p>Hello World</p>
</html>
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
teracli.defaultPackage.${system}
texlive.combined.scheme-full
typst
weasyprint
yq
zola
zsh
Expand Down

0 comments on commit 85740d6

Please sign in to comment.