for recipe in tqdm(self.recipes):
recipe.render_latex(self.latex_environment)
+ print("Generating full document...")
+ template = self.latex_environment.get_template("main.tex")
+ with open("build/main.tex", "w") as f:
+ f.write(template.render(recipes = self.recipes))
+
+ system(f"pdflatex -interaction='nonstopmode' -output-directory='build' 'build/main.tex' > /dev/zero")
+ system(f"mv build/main.pdf bread.pdf")
+
class Recipe:
def __init__(self, filename: str):
with open(path.join("src", filename), "rb") as f:
--- /dev/null
+\documentclass{article}
+
+\usepackage[margin=2cm]{geometry}
+\usepackage[scaled]{helvet}
+\usepackage[T1]{fontenc}
+\usepackage{graphicx}
+\graphicspath{{../}}
+\renewcommand\familydefault{\sfdefault}
+
+\usepackage{hyperref}
+\hypersetup{
+ colorlinks=true,
+ linkcolor=blue,
+ urlcolor=blue,
+ pdftitle={Bread Book},
+ pdfauthor={William Greenwood}
+ }
+
+\begin{document}
+
+\pagenumbering{gobble}
+
+\noindent\includegraphics[width=\textwidth]{banner}
+
+\vspace{4mm}
+
+{\noindent\large{}\textbf{William Greenwood}}
+
+\vspace{4mm}
+
+Collection of recipes with bakers percentage and example weights. Recipes are stored in TOML format and periodically compiled to the website (\url{https://bread.ozva.co.uk}) and the accompanying printouts. This is done with a tool I built. Temperatures are listed in celceus and should be assumed to be with fan when refering to baking. Currently |~ recipes|length ~| recipes at last compilation (\today{}).
+
+\vspace{4mm}
+
+\begin{enumerate}
+ \itemsep0em
+ |% for recipe in recipes %|
+ \item \textbf{|~ recipe.recipe.information.title ~|}. |~ recipe.recipe.information.description ~|
+ |% endfor %|
+\end{enumerate}
+
+\newpage
+
+|% for recipe in recipes %|
+
+ |% set recipe = recipe.recipe %|
+
+ \section{|~ recipe.information.title ~|}
+
+ |~ recipe.information.description ~|
+
+ \subsection*{Notes}
+
+ |~ recipe.information.notes|replace("\n", "\n\n")|replace("%", "\%")|replace("#", "\#") ~|
+
+ \subsection*{Ingredients}
+
+ \renewcommand{\arraystretch}{1.2}
+ \begin{tabular}{lllllll}
+ & \textbf{Bakers \%} & \textbf{500g total} & \textbf{1kg total} & \textbf{2kg total} & \textbf{3kg total} & \textbf{4kg total} \\
+ \hline
+ |% for name, weight in recipe.ingredients.items() %|
+ |~ name|replace("-", " ")|title ~| &
+ |~ weight ~|\% &
+
+ |% macro weighted(multiplier) %|
+ |% set rounded = (weight * recipe.kg * multiplier)|round|int %|
+ |% set real = (weight * recipe.kg * multiplier)|round(2) %|
+ |% set error = (real - rounded)|abs %|
+ |% if error < real * 0.05 %|
+ |~ rounded ~|
+ |% else %|
+ |~ real ~|
+ |% endif %|
+ |% endmacro %|
+
+ |~ weighted(0.5) ~| &
+ |~ weighted(1) ~| &
+ |~ weighted(2) ~| &
+ |~ weighted(3) ~| &
+ |~ weighted(4) ~| \\
+ |% endfor %|
+ \end{tabular}
+
+ \newpage
+
+|% endfor %|
+
+\end{document}
\usepackage[T1]{fontenc}
\renewcommand\familydefault{\sfdefault}
+\usepackage{hyperref}
+\hypersetup{
+ colorlinks=true,
+ linkcolor=blue,
+ urlcolor=blue,
+ pdftitle={|~ recipe.information.title ~|},
+ pdfauthor={William Greenwood}
+ }
+
\begin{document}
\section*{|~ recipe.information.title ~|}
\subsection*{Notes}
-|~ recipe.information.notes|replace("\n", "\n\n")|replace("%", "\%") ~|
+|~ recipe.information.notes|replace("\n", "\n\n")|replace("%", "\%")|replace("#", "\#") ~|
\subsection*{Ingredients}