diff options
author | Oxbian <got.dacs@slmail.me> | 2023-06-26 23:37:38 +0200 |
---|---|---|
committer | Oxbian <got.dacs@slmail.me> | 2023-06-26 23:37:38 +0200 |
commit | e6aa30561384551078e5b4220c5f1bf7a1173f90 (patch) | |
tree | 4e4bdb8a00f3b445d964ef128a10a8590ad5014e /markdown_parser.py | |
parent | dca57b84d8e6357c958b4a6d4e8a77f3ca43c2dc (diff) | |
download | blog-generator-e6aa30561384551078e5b4220c5f1bf7a1173f90.tar.gz blog-generator-e6aa30561384551078e5b4220c5f1bf7a1173f90.zip |
Adding tags system
Diffstat (limited to 'markdown_parser.py')
-rw-r--r-- | markdown_parser.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/markdown_parser.py b/markdown_parser.py index 2b9be27..403b9e4 100644 --- a/markdown_parser.py +++ b/markdown_parser.py @@ -38,7 +38,7 @@ def parsemd(filepath, env_vars): filepath: Filepath of the markdown file return: a dictionnary containing title, metadata, local path, content for HTML """ - content = {'content': '', 'title': '', 'date': '01-01-0001', 'description': '', 'filepath': env_vars['pages_path'].replace(env_vars['parent_path'] + '/', '') + content = {'content': '', 'title': '', 'date': '01-01-0001', 'description': '', 'tags' : [], 'filepath': env_vars['pages_path'].replace(env_vars['parent_path'] + '/', '') + '/' + filepath.split('.')[0] + '.html'} inmeta, inquote, inpre, inul = False, False, False, False @@ -61,6 +61,15 @@ def parsemd(filepath, env_vars): # Getting the description metadata if inmeta and line.startswith('description:'): content['description'] = line.split(':')[1].strip() + + # Getting the tags metadata + if inmeta and line.startswith('tags:'): + tags = line.split(':')[1].split(',') + + # Removing leading and ending white spaces + for i in range(0, len(tags)): + tags[i] = tags[i].strip() + content['tags'] = tags # Close quote if not quoting if inquote and not line.startswith(">"): |