From ad2910a1532ccd6a8cb3c7d2b07ca5f40c3ac1b8 Mon Sep 17 00:00:00 2001 From: GeoJulien Date: Tue, 21 Feb 2023 20:58:56 +0100 Subject: [PATCH] Handle abstract_chars_count set to 0 --- mkdocs_rss_plugin/util.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mkdocs_rss_plugin/util.py b/mkdocs_rss_plugin/util.py index 3ba823a0..8585a361 100644 --- a/mkdocs_rss_plugin/util.py +++ b/mkdocs_rss_plugin/util.py @@ -366,6 +366,14 @@ def get_description_or_abstract(self, in_page: Page, chars_count: int = 160) -> # return the description. if description and chars_count is not None: return description + # If no description and chars_count set to 0, return empty string + elif not description and chars_count == 0: + logger.warning( + f"[rss-plugin] No description set for page {in_page.file} " + "and 'abstract_chars_count' set to 0. The feed won't be compliant, " + "because an item must have a description." + ) + return "" # If chars count is unlimited, use the html content elif in_page.content and chars_count is None: if chars_count is None or len(in_page.content) < chars_count: