Skip to content

Export bookmarks and notes as readable text or HTML (#1106) - #1114

Open
GauravTheCoder wants to merge 2 commits into
trypsynth:masterfrom
GauravTheCoder:feature/export-annotations-1106
Open

GauravTheCoder wants to merge 2 commits into
trypsynth:masterfrom
GauravTheCoder:feature/export-annotations-1106

Conversation

@GauravTheCoder

Copy link
Copy Markdown
Contributor

Fixes #1106.

Adds File > Export Notes and Bookmarks as Text or HTML (Ctrl+Alt+E), so bookmarks and notes can be read without Paperback or the book. The existing .paperback export is unchanged.

What it does

  • A dialog asks what to export (bookmarks and notes, bookmarks only, or notes only), whether to include the passage each note is attached to (on by default), and whether to number the entries (off by default).
  • The save dialog then offers Text, HTML and Paperback files. The file extension picks the format. Choosing .paperback writes the same transfer file as Export Document Data, so one command covers all three. The options above do not apply to it.
  • The dialog remembers its last choices in the app settings.
  • A bookmark with no note always shows its passage, so no row is empty.
  • Audio bookmarks show a timestamp, since they have no text.
  • HTML output is a standalone UTF-8 page with an ordered list when numbered. Notes and passages are escaped.

How it works

  • export/annotations.rs (new) renders a list of entries to text or HTML. It is a pure function, so it is tested without a document.
  • render_annotations_export (new, session/links.rs) builds the entries from get_filtered_bookmarks, and gets each passage with get_line_text or get_text_range.
  • dialogs/export_annotations.rs (new) is the options dialog. Its choices are stored under three export_annotations_* app settings keys, so the config schema does not change.
  • handle_export_notes_and_bookmarks (new, menu_file.rs) shows both dialogs with the document-manager lock released, and takes it only to read the file name and to render.
  • The new ActionId::ExportNotesAndBookmarks has a default shortcut of Ctrl+Alt+E, which can be changed in Customize Keyboard Shortcuts.

Known limits

  • The format comes from the file extension. A .paperback name with the Text type selected still writes a transfer file, and the reverse writes text.
  • Ctrl+Alt is AltGr on some keyboard layouts, as with the existing Ctrl+Alt+B, M and W shortcuts. The menu item and the rebinding dialog still work there.
  • Android, iOS, Markdown and pb CLI options are not covered.

Testing

  • New unit tests cover text and HTML output, numbering, passage on and off, a bookmark with no note, an audio bookmark, an empty list and HTML escaping.
  • cargo clippy --all-targets reports no new warnings in the changed files. The workspace tests pass: paperback 144, paperback-core 1319 (24 ignored). The formatting check is clean on the pinned nightly.
  • Tried by hand on Windows with a separate config directory (PAPERBACK_CONFIG_DIR), so my own bookmarks and notes were untouched.

Strings

I added 12 strings to po/paperback.pot. The other .po files are left for the machine-translation workflow.

Adds File > Export Notes and Bookmarks as Text or HTML (Ctrl+Alt+E). A dialog picks bookmarks, notes or both, whether to include each note's passage, and whether to number the entries. The save dialog offers .txt, .html and .paperback, chosen by the file's extension. The last choices are remembered.
…notations-1106

# Conflicts:
#	crates/paperback/src/ui/main_window/menu_file.rs
#	po/paperback.pot

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Export Notes and Bookmarks Separately in TXT or HTML Format

1 participant