Compare commits

...

1 Commits

Author SHA1 Message Date
694d4b74a4 Ajoute un cache pour l'HTML généré 2025-07-27 16:49:31 +02:00

View File

@@ -14,7 +14,7 @@ def new_page(title: str, path: Path) -> Path:
today = date.today().strftime("%Y-%m-%d")
filename = path + '/' + re.sub("[^a-zA-Z0-9-]", "_", title) + ".md"
filename = path + "/" + re.sub("[^a-zA-Z0-9-]", "_", title) + ".md"
id = uuid.uuid4()
content = textwrap.dedent(
f"""\
@@ -43,6 +43,8 @@ class Page:
md_content = ""
filename = ""
_cache = ""
def __init__(self, filename: Path):
"""Constructeur : nouvelle page"""
self.filename = filename
@@ -84,10 +86,12 @@ class Page:
def html(self) -> str:
"""Convertit le markdown en html"""
return markdown.markdown(
if not self._cache:
self._cache = markdown.markdown(
self.md_content, extensions=["codehilite", "fenced_code"]
)
return self._cache
def html_template(self, template: jinja2.Template) -> str:
"""Convertit la page en html a partir d'un template jinja2"""