strip tags before manually wrapping in html

This commit is contained in:
cellarspoon 2021-12-17 18:04:19 +01:00
parent 8fb8648827
commit a27bf4a2f7
No known key found for this signature in database
GPG Key ID: 03789458B3D0C410

View File

@ -53,39 +53,39 @@ def make_cards(filepath, db_path, side_a, side_b):
def select_fields(fields, content, styles, book):
if "title" in fields:
tag = "<font size=12>{}</font>".format(book.title)
ptitle = Paragraph(strip_tags(tag), styles["Italic"])
tag = "<font size=12>{}</font>".format(strip_tags(book.title))
ptitle = Paragraph(tag, styles["Italic"])
content.append(ptitle)
content.append(Spacer(1, 12))
if "timestamp" in fields:
tag = "<font size=10>Timestamp: {}</font>".format(book.timestamp)
ptime = Paragraph(strip_tags(tag), styles["Normal"])
tag = "<font size=10>Timestamp: {}</font>".format(strip_tags(book.timestamp))
ptime = Paragraph(tag, styles["Normal"])
content.append(ptime)
content.append(Spacer(1, 12))
if "comments" in fields:
trimmed = " ".join([c.text for c in book.comments]).split()[:NUM_WORDS_COMMENT]
comments = " ".join(trimmed)
tag = "<font size=10>{}</font>".format(comments)
pcomments = Paragraph(strip_tags(tag))
comments = "{}...".format(" ".join(trimmed))
tag = "<font size=10>{}</font>".format(strip_tags(comments))
pcomments = Paragraph(tag)
content.append(pcomments)
if "authors" in fields:
format_string = "<font size=12>{}</font>"
all_authors = [author.name for author in book.authors]
all_authors = [strip_tags(author.name) for author in book.authors]
glued_together = format_string.format(", ".join(all_authors))
p = Paragraph(strip_tags(glued_together), styles["Normal"])
p = Paragraph(glued_together, styles["Normal"])
content.append(p)
content.append(Spacer(6, 12))
if "tags" in fields:
format_string = "<font size=10>{}</font>"
all_tags = [tag.name for tag in book.tags]
all_tags = [strip_tags(tag.name) for tag in book.tags]
tags_glued_together = format_string.format(", ".join(all_tags))
p = Paragraph(strip_tags(tags_glued_together), styles["Normal"])
p = Paragraph(tags_glued_together, styles["Normal"])
content.append(p)
content.append(Spacer(6, 12))