#!/bin/bash

if [ "$1" = "DEBUG" ]; then
  tex_file=result.tex
  python3 notebook/gen_latex.py --header=notebook/header.tex --output=$tex_file
else
  tex_file=$(mktemp)
  python3 notebook/gen_latex.py --header=notebook/header.tex --output=$tex_file

  #pdflatex $tex_file -halt-on-error -output-directory . && 
  #pdflatex $tex_file -halt-on-error -output-directory .
  lualatex $tex_file -halt-on-error -output-directory . && 
  lualatex $tex_file -halt-on-error -output-directory .

  mv tmp.pdf caderno.pdf
  rm tmp*
fi