From a3444bea9df8f87e6b1c4b4cd3b9a67e6c24af6e Mon Sep 17 00:00:00 2001 From: cellarspoon Date: Fri, 17 Dec 2021 18:09:37 +0100 Subject: [PATCH] spacer and correct handling of ... --- temp_index.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/temp_index.py b/temp_index.py index 7eef698..f8eb399 100644 --- a/temp_index.py +++ b/temp_index.py @@ -65,11 +65,15 @@ def select_fields(fields, content, styles, book): content.append(Spacer(1, 12)) if "comments" in fields: - trimmed = " ".join([c.text for c in book.comments]).split()[:NUM_WORDS_COMMENT] - comments = "{}...".format(" ".join(trimmed)) + trimmed = " ".join([c.text for c in book.comments]).split() + if len(trimmed) > NUM_WORDS_COMMENT: + comments = "{}...".format(" ".join(trimmed[:NUM_WORDS_COMMENT])) + else: + comments = "{}".format(" ".join(trimmed[:NUM_WORDS_COMMENT])) tag = "{}".format(strip_tags(comments)) pcomments = Paragraph(tag) content.append(pcomments) + content.append(Spacer(6, 12)) if "authors" in fields: format_string = "{}"