USECASE
The aim of this page📝 is to explain how I automatically convert a Markdown file with my resume into a PDF using with a Git hook. My resume is available at .
Install Pandoc: Use Homebrew to install Pandoc:
brew install pandoc
Install MacTeX: Use Homebrew to install MacTeX for PDF generation:
brew install --cask basictex
Convert Markdown to PDF: Use Pandoc with custom geometry settings:
pandoc -V geometry:"top=2cm, bottom=1.5cm, left=2cm, right=2cm" -f markdown-implicit_figures -o "./assets/Pavol-Kutaj-Resume.pdf" index.markdown
Create Git Hook: Navigate to the Git hooks directory:
cd .git/hooks
Create Pre-commit Hook: Create apre-commitfile and open it:
touch pre-commit
nano pre-commit
Add Script to Pre-commit Hook: Add the following script:
#!/bin/sh
# Check if index.markdown is being committed
if git diff --cached --name-only | grep -q 'index.markdown'; then
# Run Pandoc command to convert Markdown to PDF
pandoc -V geometry:"top=2cm, bottom=1.5cm, left=2cm, right=2cm" -f markdown-implicit_figures -o "./assets/Placeholder-Resume.pdf" index.markdown
# Add the generated PDF to the commit
git add "./assets/Placeholder-Resume.pdf"
fi
Make Pre-commit Hook Executable: Set executable permissions for the hook:
chmod +x pre-commit
Testing the Setup: Ensureindex.markdownand the./assets/directory exist. Run the commit process to verify the hook works.
SOCIAL SHARE CARD GENERATOR