Coding 2024-02-18

By Max Woerner Chase

Okay, I got inspired to look more into generating stuff from Leo files. I think I mentioned I wanted to key some behavior off of tags, so here's what I found looking at the file.

Node tags are stored in t elements, in an attribute called __node_tags. This attribute contains a hex-encoded string; when decoded to bytes and unpickled, the result is a set containing the tags as strings.

So, assuming I remember the relationship between v and t elements correctly, v tags lay out the tree structure, and point to t elements, which contain the node text and other metadata. Of the v tags that point to a given t element, just one contains the vh element that gives the node title. I could be wrong about this in hopefully subtle ways.

However, for the purposes of this script, I'm going to generally ignore the node titles, except to find the root of the outline. So, I want to say "for each v that is a direct child of vnodes, find all v that are descendants of vnodes, such that their t attributes match, and they contain a vh element that contains the string "Draft"". Looks like the child information follows the vh element, so I will need to perform that search in all cases, in case of something non-standard going on with the tree/graph layout.

In terms of actually printing this stuff out, I should avoid loops, which my whole "tag what kind of node it is" idea should get me for free.

Anyway, I've just about run out of juice for today, so I'm going to wrap up.

Good night.