Last active
May 8, 2024 00:19
-
-
Save cab-1729/a2cdd9b8c17cca1f89a43b541d3d8b98 to your computer and use it in GitHub Desktop.
Download all LaTeX documentation from CTAN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#last run: Fri 03 May 2024 08:10:25 PM IST | |
#Program to download all CTAN Latex documentation and store it locally | |
set -x #show commands | |
cd "$(dirname "$0")" #be proper directory | |
echo "#!/bin/sh | |
#last run: $(date +'%c') | |
$(tail -n +3 "$0")" > .temp #store file with new date | |
[ -d "Source" ] || mkdir Source;[ -d "Docs" ] || mkdir Docs;[ -d "Pages" ] || mkdir Pages #make directories | |
rm Docs/*;rm -rf Source/* #clean existing documentation | |
server(){ #get all documentation hosted at server | |
mkdir "Source/$2" | |
curl -k $1 | | |
tee "Pages/$2.html" | | |
grep -oP "<a href=\"\K.*(?=\.zip\")" | | |
{ | |
while read package; do | |
curl -k "$1$package.zip" > $package.zip | |
unzip -o $package.zip -d "Source/$2" | |
doc=$(find "Source/$2/$( | |
unzip -l $package.zip | | |
head -n 4 | | |
tail -n 1 | | |
cut -d ' ' -f 15 | |
)" -regextype posix-extended -regex ".*/$package(-doc|_doc|-en|)\.pdf" | | |
tail -n 1) | |
rm $package.zip | |
[ -z "$doc" ] || ln -s "$(pwd)/$doc" Docs/$package.pdf | |
done | |
} | |
} | |
#get CTAN | |
server "https://ctan.math.washington.edu/tex-archive/macros/latex/contrib/" "latex" | |
server "https://ctan.math.washington.edu/tex-archive/macros/generic/" "generic" | |
server "https://ctan.math.illinois.edu/macros/luatex/latex/" "luatex" | |
server "https://in.mirrors.cicku.me/ctan/macros/xetex/latex/" "xelatex" | |
server "https://mirrors.mit.edu/CTAN/macros/unicodetex/latex/" "unicodetex" | |
server "https://mirror.unpad.ac.id/ctan/graphics/" "graphics" | |
# replace file with proper date | |
chmod +x .temp | |
mv .temp "$0" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment