Files
docker/latex/fmt/format.sh
2026-01-09 15:04:22 +01:00

33 lines
647 B
Bash
Executable File

#!/bin/sh
if [ ! "$1" == "" ]; then
cp .latexindent.yaml "$1/" || true
cp latexindent.yaml "$1/" || true
cd $1
fi
echo "Formatting directory $(pwd)"
if [ -f .latexindent.yaml ]; then
echo "latexindent config found"
elif [ -f latexindent.yaml ]; then
echo "latexindent config found"
else
echo "No latexindent config found. Using defaults"
fi
files=$(find . -type f | grep "\.tex")
idx=1
total=$(echo "$files" | wc -l)
for file in $files; do
echo "Processing file $idx / $total"
latexindent -s -w -l $file
idx=$((idx + 1))
done
echo "Cleaning up..."
backups=$(find . -type f | grep "\.bak")
for backup in $backups; do
rm $backup
done