mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add book titles when exporting annots from the browse annots tool
This commit is contained in:
parent
130b27219f
commit
5e53142d0c
@ -106,13 +106,21 @@ class Export(Dialog):
|
||||
'annotations': self.annotations,
|
||||
}, ensure_ascii=False, sort_keys=True, indent=2)
|
||||
lines = []
|
||||
db = current_db()
|
||||
bid_groups = {}
|
||||
for a in self.annotations:
|
||||
atype = a['type']
|
||||
if atype == 'highlight':
|
||||
render_highlight_as_text(a, lines)
|
||||
elif atype == 'bookmark':
|
||||
render_bookmark_as_text(a, lines)
|
||||
return '\n'.join(lines)
|
||||
bid_groups.setdefault(a['book_id'], []).append(a)
|
||||
for book_id, group in bid_groups.items():
|
||||
lines.append('## ' + db.field_for('title', book_id))
|
||||
lines.append('')
|
||||
for a in group:
|
||||
atype = a['type']
|
||||
if atype == 'highlight':
|
||||
render_highlight_as_text(a, lines)
|
||||
elif atype == 'bookmark':
|
||||
render_bookmark_as_text(a, lines)
|
||||
lines.append('')
|
||||
return '\n'.join(lines).strip()
|
||||
|
||||
|
||||
def render_notes(notes, tag='p'):
|
||||
|
@ -45,7 +45,7 @@ class Export(ExportBase):
|
||||
lines = []
|
||||
for hl in self.annotations:
|
||||
render_highlight_as_text(hl, lines)
|
||||
return '\n'.join(lines)
|
||||
return '\n'.join(lines).strip()
|
||||
|
||||
|
||||
class Highlights(QListWidget):
|
||||
|
Loading…
x
Reference in New Issue
Block a user