How to Auto-Refresh with Baseprinter
This guide explains how to automatically reload previews of Baseprint document snapshots in your web browser when you save a change to a source text file.
- a setup to run Baseprinter in containers (recommended)
The automatic reloading of a Baseprint preview web page occurs in three stages.
Stage 1: Save Source File Changes from a Text Editor
You can use any text editor to save changes to your source files.
The next stage will be triggered when you save a text file that is being
Some editors, like
vim on Linux, by default change files in a way that
prevents the proper functioning of file monitoring.
Either stick to monitoring a folder or, in the case of
Stage 2: Generate New HTML Preview Folder
--monitor option of
folders or files will be continuously monitored for changes.
Upon a folder or file change,
the outputs (for Baseprint snapshot, HTML, and/or PDF) will be automatically regenerated.
CTRL-C to stop
baseprinter when running with the
Stage 3: Preview Web Page Automatically Reloaded
Baseprinter will generate a folder containing a web page preview. The last stage is a local web server that can automatically trigger the reloading of preview web pages viewed in a web browser.
Locally Installed Utility
If you have installed Baseprinter locally, you will need to run a local web server with an automatic reload capability. One such utility is the NPM package live-server.
Using the Container
If you are running Baseprinter via containers,
the Baseprinter container image includes a web server that can trigger reloads.
It can be used by setting up a second shell function similar to the
baseprinter function in step two.
podman run --rm -v=.:/mnt -w=/mnt -p=8080:8080 -it \
docker.io/castedo/baseprinter bash -c "live-server site & baseprinter -o=site $*"
live-baseprinter shell function is defined, you can run the shell command:
live-baseprinter --defaults mydoc/pandocin.yaml --monitor mydoc -b=baseprint
This command operates similarly to
-o=site output option is automatically added.
After running this command,
you can navigate to
http://localhost:8080 to view
an HTML preview of the baseprint that reloads automatically.