From 284cf939ce32ed9a85c9d1b8a0d515ccc204bc0e Mon Sep 17 00:00:00 2001 From: Oxbian Date: Wed, 3 May 2023 21:43:29 +0200 Subject: =?UTF-8?q?Ajout=20des=20premi=C3=A8res=20pages,=20et=20modificati?= =?UTF-8?q?on=20du=20g=C3=A9n=C3=A9rateur=20afin=20d'avoir=20les=20citatio?= =?UTF-8?q?ns?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/page-generator.py | 78 +++++++++++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 32 deletions(-) (limited to 'tools/page-generator.py') diff --git a/tools/page-generator.py b/tools/page-generator.py index bde61a0..1257a73 100644 --- a/tools/page-generator.py +++ b/tools/page-generator.py @@ -1,7 +1,7 @@ import os articles_path = 'articles/' -generate_path = 'archives/' +generate_path = 'pages/' atom_content = "" index_content = "

Articles

\n" + inul = False + + if inpre: + content['content'] += "\n" + inpre = False return content - +def parseline(line): + # Vérifie si on a des italiques ou gras + while '*' in line: + line = line.replace('*', '', 1) + line = line.replace('*', '', 1) + while '**' in line: + line = line.replace('**', '', 1) + line = line.replace('**', '', 1) + + # Vérifie si on a des images + while '![' in line and ']' in line: + title = line.split(']')[0].split('[')[1] + link = line.split(']')[1].split('(')[1].split(')')[0] + line = line.replace('![' + title + '](' + link + ')', '' + title + '') + + # Vérifie si on a des liens + while '[' in line and ']' in line: + title = line.split(']')[0].split('[')[1] + link = line.split(']')[1].split('(')[1].split(')')[0] + line = line.replace('[' + title + '](' + link + ')', '' + title + '') + return line + def md2html(filename): content = parsemd(filename) # Contenu parsé de notre fichier markdown template = open('page_template.html', 'r').read() @@ -139,4 +153,4 @@ if __name__=="__main__": print("Génération du fichier RSS / Atom") generateAtom() print("Génération de l'index") - updateIndex() \ No newline at end of file + updateIndex() -- cgit v1.2.3