-
Notifications
You must be signed in to change notification settings - Fork 38
Description
Is it possible to somehow manually construct the Org AST and then use the write_org method to convert it back to an org file?
The use-case that I'm trying to accomplish is the following:
- Use orgize to parse an org file into the Org struct
- Serialize and store this information in a DB
- Make modifications to the DB as needed
- Derserialize this back to an Org struct
- Convert this back to an on org file using the write_org method.
Currently, I am serializing and deserializing to JSON using serde. Had to fork and make some changes to get that to work: https://github.com/samyak-jain/orgize/tree/deser. And them I'm directly storing this JSON into an sqlite storage.
However, this setup is really cumbersome to work with. The indextree data structure when serialized to a JSON, doesn't lend itself very well to making changes to the structure. There's a whole lot of duplication of the same element across the structure. While it may be a good way to store the representation, it seems to be really hard to make modifications to it.
I would be interested to know thoughts on:
- Is there an easier to work with representation that we can convert back and forth from? I know there is an iterator over events which seems to slightly better but I don't see a way to get the Org structure back from that.
- Having APIs to more easily modify the Org sturcuture directly? This isn't as ideal since I cannot independently modify the DB and will reply on derserializing to the Org struct and then making modifications everytime.
Is there something missing? Would love to know if there are better ways to tackle this.