Files
docker/latex/fmt/format.sh

39 lines
791 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
if [ -f .latexindent.yaml ]; then
rm .latexindent.yaml "$1/" || true
elif [ -f latexindent.yaml ]; then
rm latexindent.yaml "$1/" || true
fi