From 57ccdfae66aad9f3969e37e77a1bb6b5d550ec1e Mon Sep 17 00:00:00 2001 From: Oxbian Date: Wed, 10 May 2023 21:56:04 +0200 Subject: =?UTF-8?q?Corrections=20de=20petits=20bugs=20/=20fautes,=20modifi?= =?UTF-8?q?cations=20mineures=20du=20script=20python=20pour=20accepter=20l?= =?UTF-8?q?es=20carac=C3=A8tres=20sp=C3=A9ciaux=20pour=20le=20HTML?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/page-generator.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/page-generator.py b/tools/page-generator.py index 1257a73..63526cb 100644 --- a/tools/page-generator.py +++ b/tools/page-generator.py @@ -1,4 +1,5 @@ import os +import html articles_path = 'articles/' generate_path = 'pages/' @@ -79,8 +80,12 @@ def parsemd(filename): content['content'] += "\n" inpre = False return content - + +"""Parse une ligne de texte afin d'enlever les caractères spéciaux html, les liens, et symboles gras / italiques du markdown""" def parseline(line): + # Change les &, <, > pour le support en HTML + html.escape(line) + # Vérifie si on a des italiques ou gras while '*' in line: line = line.replace('*', '', 1) @@ -102,6 +107,7 @@ def parseline(line): line = line.replace('[' + title + '](' + link + ')', '' + title + '') return line +"""Fonction pour transformer un fichier markdown en page html""" def md2html(filename): content = parsemd(filename) # Contenu parsé de notre fichier markdown template = open('page_template.html', 'r').read() -- cgit v1.2.3