# First convert the notebook into a HTML page

nb_path=$1
empty_string=""
nb_path_without_ext=$(echo "$nb_path" | sed "s/.ipynb/$empty_string/")

jupyter nbconvert --to html $nb_path

# Then convert the HTML into a PDF with Weasyprint

weasyprint -s /home/mb/public_html/notebooks-in-the-room/nbprint.css $nb_path_without_ext.html $nb_path_without_ext.pdf

# Then convert the PDF into a booklet PDF

pdfbook2 $nb_path_without_ext.pdf --no-crop --paper a4paper
