Skip to content

Instantly share code, notes, and snippets.

@randomcamel
Created November 14, 2018 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save randomcamel/7f27694e65680ac7d7388bb5303fddbf to your computer and use it in GitHub Desktop.
Save randomcamel/7f27694e65680ac7d7388bb5303fddbf to your computer and use it in GitHub Desktop.
# Install prereqs with Homebrew:
#
# uninstall moreutils if installed:
# `brew uninstall moreutils`
#
# brew install wget
# brew install poppler
# brew install parallel
# brew install moreutils --without-parallel
set -e
BASE="https://www.vaultproject.io/"
wget --spider -nd -r "${BASE}docs/index.html" --no-parent -nv -o - | while read line;
do
echo $line | grep -o "https://[^ ]\+" | grep ".html$" | sed -E "s=${BASE}(.+)=\1 ${BASE}\1=";
done | parallel -t -C' ' 'mkdir -p {1//}; /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --headless --print-to-pdf={1.}.pdf {2}'
find docs -name index.pdf | while read line; do
mv $line $(echo $line | sed 's/index.pdf/_.pdf/');
done
mkdir -p out
find -s docs -iname "*.pdf" | parallel -X 'pdfunite {} out/{#}.pdf'
pdfunite $(ls -1 out/*.pdf | sort -n) out/vault.pdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment