Improve formatting of notes in the browse details panel

This commit is contained in:
Kovid Goyal 2020-07-15 21:13:00 +05:30
parent 62da3d119e
commit 673bcb3b2b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -395,15 +395,29 @@ class DetailsPanel(QWidget):
a = prepare_string_for_xml a = prepare_string_for_xml
paras = [] paras = []
def p(text, tag='p'):
paras.append('<{0}>{1}</{0}>'.format(tag, a(text)))
if annot['type'] == 'bookmark': if annot['type'] == 'bookmark':
paras.append(a(annot['title'])) p(annot['title'])
elif annot['type'] == 'highlight': elif annot['type'] == 'highlight':
paras.append(a(annot['highlighted_text'])) p(annot['highlighted_text'])
paras.append(a(annot.get('notes') or '')) notes = annot.get('notes')
if notes:
for para in paras: p(_('Notes'), 'h4')
annot_text += '<div style="text-align:left">' + para + '</div><div>&nbsp;</div>' current_lines = []
for line in notes.splitlines():
if line:
current_lines.append(line)
else:
if current_lines:
p('\n'.join(current_lines))
current_lines = []
if current_lines:
p('\n'.join(current_lines))
annot_text += '\n'.join(paras)
date = QDateTime.fromString(annot['timestamp'], Qt.ISODate).toLocalTime().toString(Qt.SystemLocaleShortDate) date = QDateTime.fromString(annot['timestamp'], Qt.ISODate).toLocalTime().toString(Qt.SystemLocaleShortDate)
text = ''' text = '''
<h2 style="text-align: center">{title} [{book_format}]</h2> <h2 style="text-align: center">{title} [{book_format}]</h2>