Skip to content

Commit

Permalink
add translator to email
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Morris committed Nov 5, 2023
1 parent 3bddf0f commit ddfa25e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 16 additions & 1 deletion poems/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,22 @@ def nice_fancy_date(self):

@property
def html_lines(self):
return utils.text_to_html_lines(self.body)
body_text = self.body.replace("--", "—") # convert emdashes
body_text = utils.add_italic_tags(body_text)

parsed_lines = []
for line in body_text.split("\n"):
if len(line) > 0:
parsed_lines.append(f'<div class="opus-line">{line.strip()}</div>')
else:
parsed_lines.append(f'<div class="opus-line-blank">&#8203;</div>')

if "translator" in self.metadata.keys():
parsed_lines.append(f'<div class="opus-line-blank">&#8203;</div>')
parsed_lines.append(f'<div class="opus-line-blank">&#8203;</div>')
parsed_lines.append(f'<div class="opus-line"><i>Translated by {self.metadata["translator"]}</i></div>')

return "\n".join(parsed_lines)

@property
def header(self):
Expand Down
2 changes: 1 addition & 1 deletion poems/tests/test_curator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ def test_dates():
poem = curator.get_poem(author=author, verbose=False)
print(f'{author:>16}: {poem.author.dates}')

print(curator.poems)
print(poem.html_lines)

0 comments on commit ddfa25e

Please sign in to comment.