bluesky: Start compilation
This commit is contained in:
parent
5ac1e637fc
commit
bad56eb06a
8 changed files with 3980 additions and 0 deletions
45
Bluesky problems/build.sh
Executable file
45
Bluesky problems/build.sh
Executable file
|
|
@ -0,0 +1,45 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
basedir="$(dirname "$0")"
|
||||
basedir="$(realpath "$basedir")"
|
||||
cd "$basedir"
|
||||
name="$(basename "$(pwd)")"
|
||||
|
||||
# Check if we want to run against a certain translation
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "Please specify the language you want to build (eg. fr)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TARGETLANG="$1"
|
||||
SOURCEFILE="main.${TARGETLANG}.typ"
|
||||
TARGETFILE="$name".$TARGETLANG.pdf
|
||||
TARGETFILEBOOK="$name".${TARGETLANG}-book.pdf
|
||||
|
||||
if ! typst compile --root .. ./"$SOURCEFILE" ./"$TARGETFILE"; then
|
||||
echo "Failed to compile "$name"/"$SOURCEFILE". Please fix errors and run me again."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Compiled read mode. Now compiling print mode."
|
||||
|
||||
if ! command -v pdfbook2; then
|
||||
echo "ERROR: pdfbook2 not installed. Not compiling print mode."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
t="$(mktemp --suffix=.pdf)"
|
||||
typst compile --input format=booklet --root .. ./"$SOURCEFILE" "$t"
|
||||
|
||||
# Need to be in the folder there for it to work, otherwise it
|
||||
# tries to rename from current partition to /tmp which of course fails
|
||||
parent="$(dirname "$t")"
|
||||
newFileName="$(basename "$t" .pdf)-book.pdf"
|
||||
newFile="$parent"/"$newFileName"
|
||||
cd "$parent"
|
||||
|
||||
pdfbook2 --paper=a4paper "$t" --no-crop --outer-margin=0 --inner-margin=0 --top-margin=0 --bottom-margin=0
|
||||
|
||||
cd "$basedir"
|
||||
cp "$newFile" "$TARGETFILEBOOK"
|
||||
echo "Booklet available in $TARGETFILEBOOK"
|
||||
Loading…
Reference in a new issue