Files
pandoc/wasm/Makefile
T
John MacFarlane 4b26f50118 Add support for compiling pandoc.wasm.
'make pandoc.wasm' will compile a wasm version of pandoc.

This also adds a 'repl' flag to pandoc-lua-engine, so that
support for a Lua repl can be disabled for the wasm build.

A new wasm directory contains:

- pandoc.js, a JavaScript wrapper for pandoc.wasm
- index.html + index.js, a web app exposing all of pandoc's
  functionality in a GUI interface
- a set of illustrative examples that can be loaded from the web app

Most of the code in index.html and index.js has been produced in
interaction with Claude code.
2026-02-01 14:50:50 +01:00

34 lines
1022 B
Makefile

SHA1_PANDOC_WASM=$(shell openssl sha1 -r pandoc.wasm | sed 's/ .*$$//')
SHA1_PANDOC_JS=$(shell openssl sha1 -r pandoc.js | sed 's/ .*$$//')
SHA1_INDEX_JS=$(shell openssl sha1 -r index.js | sed 's/ .*$$//')
EXAMPLES=$(patsubst %,site/%.zip,$(shell find examples -mindepth 1 -type d))
SHA1_EXAMPLES=$(shell cat $(EXAMPLES) | openssl sha1 -r | sed 's/ .*$$//')
site: site/examples $(EXAMPLES) site/pandoc.js site/index.js site/index.html site/pandoc.wasm
site/examples:
mkdir -p $@
site/pandoc.js: pandoc.js
perl -p -e "s/SHA1_PANDOC_WASM/$(SHA1_PANDOC_WASM)/g" $< > $@
site/index.js: index.js
perl -p -e "s/SHA1_PANDOC_JS/$(SHA1_PANDOC_JS)/g; s/SHA1_EXAMPLES/$(SHA1_EXAMPLES)/g" $< > $@
site/%.html: %.html
perl -p -e "s/SHA1_INDEX_JS/$(SHA1_INDEX_JS)/g" $< > $@
site/examples/%.zip: examples/% $(wildcard examples/%/*)
cd "$<" && zip -r "$(CURDIR)/$@" .
site/%: %
cp $< $@
upload: site
rsync -av site/ website:pandoc.org/wasm-demo
.PHONY: upload
serve: site
cd site && python3 -m http.server
.PHONY: serve