trim to 50 words instead of chars

Closes #1.
This commit is contained in:
cellarspoon 2021-12-17 17:56:57 +01:00
parent f443d1ba12
commit 64dbcf16ed
No known key found for this signature in database
GPG Key ID: 03789458B3D0C410

View File

@ -12,6 +12,7 @@ from reportlab.pdfgen import canvas
from reportlab.platypus import PageBreak, Paragraph, SimpleDocTemplate, Spacer
CWD = Path().resolve()
NUM_WORDS_COMMENT = 50
from html.parser import HTMLParser
from io import StringIO
@ -64,12 +65,7 @@ def select_fields(fields, content, styles, book):
content.append(Spacer(1, 12))
if "comments" in fields:
comments = ", ".join(
[
shorten(comment.text, width=50, placeholder="...")
for comment in book.comments
]
)
comments = " ".join([c.text for c in book.comments]).split()[:NUM_WORDS_COMMENT]
tag = "<font size=10>{}</font>".format(comments)
pcomments = Paragraph(strip_tags(tag))
content.append(pcomments)