compile-sent-tables.sh (982B)
1 #!/bin/sh 2 # convert-tables.sh — Convert tables/*.md to images/tables/*.jpg, with dependency checking 3 4 MD_TABLE_TO_JPG="${MD_TABLE_TO_JPG:-md2jpg-table}" 5 6 status() { printf "[*] %s\n" "$1" >&2; } 7 8 # Dependency check 9 for dep in basename "$MD_TABLE_TO_JPG"; do 10 if ! command -v "$dep" > /dev/null 2>&1; then 11 status "Dependency not found: $dep" 12 status "Please install the missing dependency and try again." 13 exit 1 14 fi 15 done 16 17 mkdir -p images/tables 18 19 # Convert or update images from markdown files 20 for f in tables/*.md; do 21 [ -f "$f" ] || continue 22 out="images/tables/$(basename "${f%.md}.jpg")" 23 if [ ! -e "$out" ] || [ -n "$(find "$f" -prune -newer "$out")" ]; then 24 "$MD_TABLE_TO_JPG" "$f" "$out" 25 fi 26 done 27 28 # Remove .jpg files that have no corresponding .md file 29 for img in images/tables/*.jpg; do 30 [ -f "$img" ] || continue 31 base="$(basename "$img" .jpg)" 32 if [ ! -f "tables/${base}.md" ]; then 33 status "Removing orphan image $img" 34 rm "$img" 35 fi 36 done