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