Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omtex/blob/main/tools/compare.sh # omtex aien-dev/omtex Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omtex / tools / compare.sh` 32 lines ยท 2077 bytes Raw Blame History 1 #!/bin/sh 2 # compare.sh ORIG.tex ORIG.pdf OMTEX.tex OMTEX.pdf -- compare an omtex reproduction with the original. 3 # 1. text: pdftotext -layout of the published ORIG.pdf vs OMTEX.pdf (diff line count, 0 = identical) 4 # 2. pages: page counts 5 # 3. pixels: ORIG.tex compiled here with the same pdflatex, rendered at 100 dpi, page-by-page cmp 6 # with OMTEX.pdf (isolates omtex from TeX Live version differences) 7 # 4. source: word-level diff of ORIG.tex vs OMTEX.tex (whitespace-insensitive), as counted pairs 8 set -eu 9 otex=$(realpath "$1") opdf=$(realpath "$2") mtex=$(realpath "$3") mpdf=$(realpath "$4") 10 nice=${OMTEX_NICE-nice -n 19 ionice -c3} 11 W=$(mktemp -d "${TMPDIR:-/tmp}/omtex-cmp.XXXXXX") 12 trap 'rm -rf "$W"' EXIT 13 pages() { pdfinfo "$1" | awk '/^Pages/{print $2}'; } 14 echo "orig.tex sha256 $(sha256sum < "$otex" | cut -d' ' -f1)" 15 echo "orig.pdf sha256 $(sha256sum < "$opdf" | cut -d' ' -f1) producer $(pdfinfo "$opdf" | sed -n 's/^Producer: *//p')" 16 echo "omtex.tex sha256 $(sha256sum < "$mtex" | cut -d' ' -f1)" 17 echo "omtex.pdf producer $(pdfinfo "$mpdf" | sed -n 's/^Producer: *//p')" 18 pdftotext -layout "$opdf" "$W/o.txt"; pdftotext -layout "$mpdf" "$W/m.txt" 19 echo "text: published PDF vs omtex PDF differing lines: $(diff "$W/o.txt" "$W/m.txt" | grep -c '^[<>]' || true)" 20 echo "pages: published $(pages "$opdf") omtex $(pages "$mpdf")" 21 cp "$otex" "$W/orig.tex" 22 ( cd "$W" && for i in 1 2; do $nice pdflatex -interaction=nonstopmode -halt-on-error -no-shell-escape orig.tex > /dev/null; done ) 23 pdftoppm -r 100 "$W/orig.pdf" "$W/l"; pdftoppm -r 100 "$mpdf" "$W/m" 24 same=0 total=0 25 for f in "$W"/l-*.ppm; do 26 total=$((total + 1)); g=$W/m-${f##*/l-} 27 if [ -f "$g" ] && cmp -s "$f" "$g"; then same=$((same + 1)); else echo "pixels: page ${f##*/l-} differs"; fi 28 done 29 echo "pixels: original .tex built here vs omtex PDF, 100 dpi: $same/$total pages identical" 30 tr -s ' \n\t' '\n\n\n' < "$otex" > "$W/o.w"; tr -s ' \n\t' '\n\n\n' < "$mtex" > "$W/m.w" 31 echo "source word diff (count, side, token):" 32 diff "$W/o.w" "$W/m.w" | grep '^[<>]' | sort | uniq -c | sort -rn || echo " none"