6 Working with Other Bookmark Managers
hande can import from, and export to, the Netscape Bookmark File Format — the plain HTML format Firefox, Chrome, Safari, and Edge all actually use for their own “export bookmarks” and “import bookmarks” features. It’s the one format that achieves genuine interoperability with a real browser.
6.1 Importing
From the shell:
hlg> :import
Path to the browser bookmarks HTML file: bookmarks.html
Import into which category? [default]:
Preserve folder structure as nested subcategories, rather than importing flat? [y/N]
Imported 507 bookmark(s) into the 'default' category.
:import is also available as :i. The path prompt is pre-filled with bookmarks.html, since that’s what most browsers name their own export and most people never change it — press Enter to accept it as-is, or edit it for something else.
From the command line:
$ hande --import-bookmarks bookmarks.html --category default
Add --preserve-folders (or answer “yes” to the shell’s own prompt) to turn each folder in the browser export into a nested subcategory matching the file’s own structure, rather than flattening every bookmark into one list (see Chapter 2 for subcategories).
6.1.1 What happens to each imported bookmark
- Its title becomes its comment (see Chapter 5) — the human-readable text with real spaces, exactly as a browser generated it.
- Its name is a slug derived from that title: lowercase, hyphens in place of anything that isn’t alphanumeric, and capped at a reasonable length so it stays easy to work with. If two imported bookmarks would collide, a number is appended to keep them distinct.
- Its address is collapsed into hande’s own link shortcuts wherever it matches one exactly (see Chapter 3) — a plain
https://address becomes@,https://www.becomes@=, plainhttp://becomes@!, and a barehttp://localhost:PORT(or127.0.0.1) becomes@#PORT. Anything else is kept as a plain, explicit address.
6.1.2 What gets skipped
Two kinds of entries a browser export can contain aren’t real, openable bookmarks, and are silently skipped rather than imported or flagged as errors:
place:addresses — Firefox’s own internal smart-folder queries (Recently Bookmarked, Recent Tags, and the like), which are saved searches the browser runs itself, not bookmarks.javascript:addresses — bookmarklets. These are genuinely standardized across every browser, but that standard is specifically “run this code against whatever tab is currently open” — something hande, as an external program with no notion of an open browser tab, has no way to do anything useful with. Your original browser export still has these if you ever need them again; hande just can’t be the thing that runs them.
The import summary tells you how many entries were skipped this way, if any were.
6.2 Exporting
From the shell:
hlg> :export
Path to write the exported HTML file: bookmarks.html
Export only the 'default' category, rather than everything? [y/N]
Exported 24 bookmark(s) to 'bookmarks.html'.
:export is also available as :x. From the command line:
$ hande --export-bookmarks bookmarks.html
$ hande --export-bookmarks bookmarks.html --category default
Without --category, every category in your database is exported, each becoming its own folder in the resulting file, with all your global bookmarks gathered into a folder of their own called “Global”.
6.2.1 What each exported bookmark looks like
- Its title is its own comment/description, if it has one — the same human-readable text a browser would have generated in the first place, restoring exactly what import preserved there. A bookmark with no comment falls back to using its own name as the title.
- Its address is fully resolved — any link shortcut is expanded back out to a plain, explicit
http://orhttps://address, since that’s the only thing a browser understands.
6.2.2 What’s left out
- Command bookmarks (scripts, one-liners) — meaningless outside hande itself.
- A bookmark whose location is still an unresolved reference (see Appendix B) — there’s nothing to hand a browser until it’s been resolved.
- hande’s own reserved bookmarks (the ones described in Chapter 2 and Appendix D).
6.3 Advice for the round trip
If you plan to eventually export a bookmark back out to a browser, give it a proper description (Chapter 4) with the readable title you’d want it to show up as — that’s exactly what export uses. And keep in mind that hande-specific things (scripts, deactivated bookmarks, subcategory-restricted locations) don’t have anywhere to go in a plain bookmark file; a browser was never going to understand them, and export leaves them out rather than pretending otherwise.