Lets see what lighthouse says
Some checks failed
Build, Push, and Deploy to Nomad / docker-nomad (push) Has been cancelled

This commit is contained in:
2024-12-21 23:33:49 +01:00
parent 3026972dee
commit bde441326b
8 changed files with 88 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
import markdown
from jinja2 import Environment, DictLoader
from .image_controller import ImageHandler
# Define Jinja2 custom functions
def img_left_overlay(src):
"""Render an image with overlay."""
@@ -82,6 +82,8 @@ def slider(options, images):
def create_jinja_environment():
"""Create and configure the Jinja2 environment."""
env = Environment(loader=DictLoader({"base_template": "{{ content | safe }}"}))
image_handler = ImageHandler(base_dir="static/images")
env.globals.update({
"img_left_overlay": img_left_overlay,
"box": box,
@@ -89,6 +91,8 @@ def create_jinja_environment():
"warning": warning,
"link_to": link_to,
"slider": slider,
"image": image_handler.generate_image_tag, # Add image handler function
})
return env
@@ -113,11 +117,7 @@ def render_markdown_with_jinja(markdown_content: str):
template = env.get_template("base_template")
final_html = template.render(content=intermediate_html)
#Step 3: Re-render final_html in Jinja2 for embedded tags like {{ box(...) }}
try:
final_output = env.from_string(final_html).render()
except:
print(final_html)
# Step 3: Re-render final_html in Jinja2 for embedded tags like {{ image(...) }}
final_output = env.from_string(final_html).render()
return final_output, metadata