diff --git a/redstring/library.py b/redstring/library.py index 6982937..0579b6c 100644 --- a/redstring/library.py +++ b/redstring/library.py @@ -17,16 +17,18 @@ def generate_index_document(directory: str) -> Document: document: Document = load(f) # Check if this document specifies a tab, and create it if necessary. - category = document.get_tag('category') - if not category: + if category_tag := document.get_tag('category'): + category = category_tag.value + else: category = 'index' if category not in categories: categories[category] = {} category_tab = categories[category] # Check if this document specifies a topic, and create it if necessary. - topic = document.get_tag('topic') - if not topic: + if topic_tag := document.get_tag('topic'): + topic = topic_tag.value + else: topic = 'uncategorized' if '.' in topic: topic, subtopic = topic.split('.', maxsplit=1)