import json from jinja2 import Environment, FileSystemLoader import markdown2 def convert_markdown_to_html(text): return markdown2.markdown(text) def generate_html(pages): env = Environment(loader=FileSystemLoader("templates")) template = env.get_template("index.html") html = template.render(pages=pages) return html # Charger les données depuis le fichier JSON with open("all_pages.json", "r", encoding="utf-8") as f: all_pages = json.load(f) # Convertir le contenu Markdown en HTML for page in all_pages: page["content"] = convert_markdown_to_html(page["html_content"]) # Générer le HTML html = generate_html(all_pages) # Enregistrer le HTML dans un fichier with open("index.html", "w", encoding="utf-8") as f: f.write(html)