Is it possible to parse and manipulate Tinderbox's XML using Ruby?

I have been working on a new Ruby class that should now be useful enough to be worth sharing.

This ruby script will parse attributes, notes, and links belonging to a Tinderbox document. It can be used, for instance, to backup notes (with all attribute values) to a TSV file. (Wiki Links – [[link]] – can optionally be added to the text.) This could be useful to recover data from files that refuse to open.

I might add the option to retrieve other elements, such as link types, preferences, filters, colors, macros, badges, windows, searches, and gallery. But this is for a later time. All feedback and suggestions are welcome.


Dependencies

This was developed using Ruby 3.1, and it relies on Nokogiri.

I recommend installing Ruby with rbenv via Homebrew.

Homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Rbenv

brew install rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc

Ruby 3.1

Restart the terminal, install version 3.1.0 and, optionally set it as the global Ruby version for your system.

rbenv install 3.1.0
rbenv global 3.1.0

Nokogiri

Finally, install Nokogiri:

$ gem install nokogiri

Edited: Thanks, @WAKAMATSU for spoting an error here. This was previously writen Nokogiri whereas all the letters should be in lowercase.


Github gist

3 Likes