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 https://pavol.kutaj.com. It is running on Github Pages (i.e. on Jekyll). I am trying to have a short NOW section on the top of the CV that I'm updating at least every querted. With this tiny automatin, each time I edit an index.markdown
file, an accompanying .pdf
is generated locally with pandoc and the pushed together with the commit of index.markdown
. The pdf for download is available at https://pavol.kutaj.com/assets/Pavol-Kutaj-Resume.pdf.
- 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 a
pre-commit
file 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: Ensure
index.markdown
and the./assets/
directory exist. Run the commit process to verify the hook works.
Top comments (0)