add typst working docs
This commit is contained in:
@@ -0,0 +1,43 @@
|
|||||||
|
So for like live updating or recompiling the pdf document with a justfile that looks like this in one terminal window
|
||||||
|
|
||||||
|
```justfile
|
||||||
|
watch-typst doc lang="da":
|
||||||
|
typst watch --input lang={{ lang }} {{ doc }}.typ ./output/{{ doc }}-{{ lang }}.pdf
|
||||||
|
|
||||||
|
watch-pdf doc lang="da":
|
||||||
|
watch-pdf ./output/{{ doc }}-{{ lang }}.pdf
|
||||||
|
|
||||||
|
build doc:
|
||||||
|
typst compile --input lang=en {{ doc }}.typ ./output/{{ doc }}-en.pdf
|
||||||
|
typst compile --input lang=da {{ doc }}.typ ./output/{{ doc }}-da.pdf
|
||||||
|
typst compile --input lang=fo {{ doc }}.typ ./output/{{ doc }}-fo.pdf
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
While the machine having the watch-pdf script available in PATH
|
||||||
|
|
||||||
|
```bash
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
[[ -z "$1" ]] && { echo "ERROR: No PDF filename provided"; exit 1; }
|
||||||
|
PDF_PATH="$1"
|
||||||
|
|
||||||
|
if [[ ! -f "${PDF_PATH}" ]]; then
|
||||||
|
echo "ERROR: ${PDF_PATH} is not a regular file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
command -v evince &> /dev/null || { echo "❌ evince not found. Install: sudo apt-get install evince"; exit 1; }
|
||||||
|
|
||||||
|
echo "=== Reload Watcher Started ==="
|
||||||
|
echo "Monitoring ${PDF_PATH} for writes…"
|
||||||
|
|
||||||
|
while IFS= read -r change_file; do
|
||||||
|
[[ "${change_file}" == "${PDF_PATH}" ]] || continue
|
||||||
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] ${PDF_PATH} modified → opening evince"
|
||||||
|
evince "${PDF_PATH}" &
|
||||||
|
done < <(inotifywait -mr --format '%w%f' -e close_write "${PDF_PATH}")
|
||||||
|
|
||||||
|
echo "Watcher stopped."
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user