From 8fe9382024ea80847206ad7811b2ce2e4dd6d825 Mon Sep 17 00:00:00 2001 From: Oxbian Date: Sun, 25 Jun 2023 00:10:55 +0200 Subject: Fix unworking blog generator --- markdown_parser.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'markdown_parser.py') diff --git a/markdown_parser.py b/markdown_parser.py index b521a87..2b9be27 100644 --- a/markdown_parser.py +++ b/markdown_parser.py @@ -31,17 +31,17 @@ def parseline(line): return line -def parsemd(env_vars, filepath): +def parsemd(filepath, env_vars): """ Parse the markdown file and return the content to put into the template page env_vars: dictionnary of environment variable filepath: Filepath of the markdown file return: a dictionnary containing title, metadata, local path, content for HTML """ - content = {'content': '', 'title': '', 'date': '', 'description': '', 'filepath': env_vars['pages_path'].replace(env_vars['parent_path'] + '/', '') + content = {'content': '', 'title': '', 'date': '01-01-0001', 'description': '', 'filepath': env_vars['pages_path'].replace(env_vars['parent_path'] + '/', '') + '/' + filepath.split('.')[0] + '.html'} - inmeta, inquote, inpre, inul = False, False, False + inmeta, inquote, inpre, inul = False, False, False, False # Reading the content of the file and transform into html for line in open(env_vars['markdown_path'] + '/' + filepath, "r"): @@ -59,7 +59,7 @@ def parsemd(env_vars, filepath): content['date'] = line.split(':')[1].strip() # Getting the description metadata - if line.startswith('description:'): + if inmeta and line.startswith('description:'): content['description'] = line.split(':')[1].strip() # Close quote if not quoting @@ -89,12 +89,12 @@ def parsemd(env_vars, filepath): inquote = True # Checking if it's a list - elif line.startswith("-"): + elif line.startswith("-") and not line.startswith("---"): if inul: content['content'] += "\n" - content['content'] += "
  • " + parseline(line.lstrip("- ")) + content['content'] += "\t
  • " + parseline(line.lstrip("- ")) else: - content['content'] += "\n" inul = False if inpre: -- cgit v1.2.3