diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/page-generator.py | 8 |
1 files changed, 7 insertions, 1 deletions
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'] += "</code></pre>\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('*', '<i>', 1) @@ -102,6 +107,7 @@ def parseline(line): line = line.replace('[' + title + '](' + link + ')', '<a href="' + link + '">' + title + '</a>') 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() |