tempdir=$(mktemp -d)

echo \`\`\` > $tempdir/gitlog.md
git log --reverse --stat --format=\`\`\`%n##\ %s%n%n\`\`\`%n%n%H%n%ai%n%an\ \<%ae\>%n\`\`\`%n\ \ %b%nFiles\ changed:%n\`\`\` >> $tempdir/gitlog.md
echo \`\`\` >> $tempdir/gitlog.md
echo \\newpage >> $tempdir/gitlog.md
echo \\tableofcontents\\label{toc} >> $tempdir/gitlog.md

echo '
---
title:  "Changelog of nse-madec project"
header-includes: |
   \usepackage{sectsty}
   \allsectionsfont{\mdseries\sectionrule{6ex}{0pt}{1.5ex}{0pt}}
   \usepackage{hyperref}
   \hypersetup{hidelinks}
   \usepackage{setspace}
   \onehalfspacing
   \usepackage{etoolbox}
   \BeforeBeginEnvironment{verbatim}{\def\baselinestretch{0.75}}
   \usepackage{newunicodechar}
   \newfontfamily\extendedfont{DejaVu Serif}
   
   \iffontchar\font`├ \else \newunicodechar{├}{{\extendedfont ├}} \fi
   
   \iffontchar\font`─ \else \newunicodechar{─}{{\extendedfont ─}} \fi

   \iffontchar\font`└ \else \newunicodechar{└}{{\extendedfont └}} \fi
   
   \iffontchar\font`∞ \else \newunicodechar{∞}{{\extendedfont ∞}} \fi

fontsize: 10pt
mainfont: "Utopia"
monofont: "inconsolata"
monofontoptions: "Scale=0.8"
...
The changelog of nse-madec progect generated from git log. \textit{\hyperref[toc]{The table of contents is at the end of the document.}} ' > $tempdir/gitlog.yaml

pandoc --pdf-engine=lualatex -s  $tempdir/gitlog.yaml $tempdir/gitlog.md  -o gitlog.md
pandoc --toc --pdf-engine=lualatex -s  $tempdir/gitlog.yaml $tempdir/gitlog.md  -o gitlog.tex
pandoc --pdf-engine=lualatex -s  $tempdir/gitlog.yaml $tempdir/gitlog.md  -o gitlog.pdf

rm $tempdir/gitlog.md
rm $tempdir/gitlog.yaml
rmdir $tempdir

