from jinja2 import Environment, FileSystemLoader
from datetime import datetime
from tqdm import tqdm
+import re
class RecipeBook:
def __init__(self):
def render_html(self, environment: Environment):
template = environment.get_template("template.html")
+ self.recipe['information']['notes'] = re.sub(
+ r"(?P<color>#[\da-fA-F]{6})",
+ r"<span style='background-color:\g<color>;color:white'>\g<color></span>",
+ self.recipe['information']['notes']
+ )
+
with open(path.join("recipes", self.recipe["html"]), "w") as f:
f.write(template.render(recipe = self.recipe, time = datetime.now()))
img {
width: 100%;
}
+p {
+ text-align: justify;
+}
p + p {
text-indent: 1.5em;
}
dt {
font-weight: bold;
}
+
+@media (prefers-color-scheme: dark) {
+ body {
+ color: gray;
+ background-color: black;
+ }
+}
+
+@media print {
+ body {
+ font-size: 12px;
+ }
+ main {
+ width: 100%;
+ }
+ nav, a, p:last-of-type {
+ display: none;
+ }
+ p:first-of-type:after {
+ content: " Printed from https://bread.ozva.co.uk.";
+ }
+}
<main>
<a href="../index.html">Back to main page</a>
<h1>{{ recipe.information.title }}</h1>
+ <nav>
<a href="https://git.ozva.co.uk/?p=bread;a=history;f=src/{{ recipe.filename }};">[History]</a> -
- <a href="{{ recipe.pdf }}">[PDF]</a>
+ <a href="{{ recipe.pdf }}">[PDF]</a> -
+ <em>Printable with Ctrl+P</em>
+ </nav>
<p>{{ recipe.information.description }}</p>
<h2>Notes</h2>