Merge 859ca43c2cf137f152663b7fab60da1f30a23c83 into cf4a12acb3a70951fd59d67e0738bf3ab2d1045c

This commit is contained in:
Emre AKYÜZ 2024-03-30 10:57:55 +03:00 committed by GitHub
commit c2ba22ccea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,58 +2,51 @@
# This script will compile or run another finishing operation on a document. I # This script will compile or run another finishing operation on a document. I
# have this script run via vim. # have this script run via vim.
#
# Compiles .tex. groff (.mom, .ms), .rmd, .md, .org. Opens .sent files as sent # Compiles .tex. groff (.mom, .ms), .rmd, .md, .org. Opens .sent files as sent
# presentations. Runs scripts based on extension or shebang. # presentations. Runs scripts based on extension or shebang.
#
# Note that .tex files which you wish to compile with XeLaTeX should have the # Note that .tex files which you wish to compile with XeLaTeX should have the
# string "xelatex" somewhere in a comment/command in the first 5 lines. # string "xelatex" somewhere in a comment/command in the first 5 lines.
file=$(readlink -f "$1") file="${1}"
ext="${file##*.}"
dir=${file%/*} dir=${file%/*}
base="${file%.*}" base="${file%.*}"
ext="${file##*.}"
cd "$dir" || exit 1 cd "${dir}" || exit "1"
textype() { \ case "${ext}" in
textarget="$(getcomproot "$file" || echo "$file")" [0-9]) preconv "${file}" | refer -PS -e | groff -mandoc -T pdf > "${base}.pdf" ;;
echo "$textarget" mom|ms) preconv "${file}" | refer -PS -e | groff -T pdf -m"${ext}" > "${base}.pdf" ;;
command="pdflatex" c) cc "${file}" -o "${base}" && "./${base}" ;;
( head -n5 "$textarget" | grep -qi 'xelatex' ) && command="xelatex" cpp) g++ "${file}" -o "${base}" && "./${base}" ;;
$command --output-directory="${textarget%/*}" "${textarget%.*}" cs) mcs "${file}" && mono "${base}.exe" ;;
grep -qi addbibresource "$textarget" && go) go run "${file}" ;;
biber --input-directory "${textarget%/*}" "${textarget%.*}" && h) sudo make install ;;
$command --output-directory="${textarget%/*}" "${textarget%.*}" && java) javac -d classes "${file}" && java -cp classes "${base}" ;;
$command --output-directory="${textarget%/*}" "${textarget%.*}" m) octave "${file}" ;;
} md) [ -x "$(command -v lowdown)" ] && \
lowdown --parse-no-intraemph "${file}" -Tms | groff -mpdfmark -ms -kept -T pdf > "${base}.pdf" || \
case "$ext" in [ -x "$(command -v groffdown)" ] && \
# Try to keep these cases in alphabetical order. groffdown -i "${file}" | groff -T pdf > "${base}.pdf" || \
[0-9]) preconv "$file" | refer -PS -e | groff -mandoc -T pdf > "$base".pdf ;; pandoc -t ms --highlight-style="kate" -s -o "${base}.pdf" "${file}" ;;
c) cc "$file" -o "$base" && "$base" ;; org) emacs "${file}" --batch -u "${USER}" -f org-latex-export-to-pdf ;;
cpp) g++ "$file" -o "$base" && "$base" ;; py) python "${file}" ;;
cs) mcs "$file" && mono "$base".exe ;; [rR]md) Rscript -e "rmarkdown::render('${file}', quiet=TRUE)" ;;
go) go run "$file" ;; rs) cargo build ;;
h) sudo make install ;; sass) sassc -a "${file}" "${base}.css" ;;
java) javac -d classes "$file" && java -cp classes "${1%.*}" ;; scad) openscad -o "${base}.stl" "${file}" ;;
m) octave "$file" ;; sent) setsid -f sent "${file}" 2> "/dev/null" ;;
md) if [ -x "$(command -v lowdown)" ]; then tex)
lowdown --parse-no-intraemph "$file" -Tms | groff -mpdfmark -ms -kept -T pdf > "$base".pdf textarget="$(getcomproot "${file}" || echo "${file}")"
elif [ -x "$(command -v groffdown)" ]; then command="pdflatex"
groffdown -i "$file" | groff -T pdf > "$base".pdf head -n5 "${textarget}" | grep -qi "xelatex" && command="xelatex"
else ${command} --output-directory="${textarget%/*}" "${textarget%.*}" &&
pandoc -t ms --highlight-style=kate -s -o "$base".pdf "$file" grep -qi addbibresource "${textarget}" &&
fi ; ;; biber --input-directory "${textarget%/*}" "${textarget%.*}" &&
mom) preconv "$file" | refer -PS -e | groff -mom -kept -T pdf > "$base".pdf ;; ${command} --output-directory="${textarget%/*}" "${textarget%.*}" &&
ms) preconv "$file" | refer -PS -e | groff -me -ms -kept -T pdf > "$base".pdf ;; ${command} --output-directory="${textarget%/*}" "${textarget%.*}"
org) emacs "$file" --batch -u "$USER" -f org-latex-export-to-pdf ;; ;;
py) python "$file" ;; *) sed -n '/^#!/s/^#!//p; q' "${file}" | xargs -r -I % "${file}" ;;
[rR]md) Rscript -e "rmarkdown::render('$file', quiet=TRUE)" ;;
rs) cargo build ;;
sass) sassc -a "$file" "$base".css ;;
scad) openscad -o "$base".stl "$file" ;;
sent) setsid -f sent "$file" 2>/dev/null ;;
tex) textype "$file" ;;
*) sed -n '/^#!/s/^#!//p; q' "$file" | xargs -r -I % "$file" ;;
esac esac