Last active
January 9, 2024 04:49
-
-
Save isurfer21/465d33ecdb8c36aefbaa13b18bb87c01 to your computer and use it in GitHub Desktop.
Markdown to PDF converter CLI wrapper made using Pandoc
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/zsh | |
# This script takes three arguments: input filename, output filename and optional font-face name | |
# It uses pandoc to convert the input file to a pdf file with specified options | |
# If no font-face name is provided, it defaults to 'Optima' | |
# Check if the number of arguments is correct | |
if [ $# -lt 2 ] || [ $# -gt 3 ]; then | |
echo "Usage: ${0##*/} input.md output.pdf [font-face]" | |
exit 1 | |
fi | |
# Assign the arguments to variables | |
input_file=$1 | |
output_file=$2 | |
font_face=${3:-Optima} | |
# Run the pandoc command with the input and output files and the font-face option | |
pandoc -s -V geometry:margin=.75in --pdf-engine=xelatex -V mainfont:"$font_face" -o "$output_file" "$input_file" | |
# Check if the conversion was successful | |
if [ $? -eq 0 ]; then | |
echo "Conversion successful!" | |
else | |
echo "Conversion failed!" | |
exit 2 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment