Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot parse Roam EDN exports #85

Closed
jrk opened this issue Dec 21, 2020 · 3 comments
Closed

Cannot parse Roam EDN exports #85

jrk opened this issue Dec 21, 2020 · 3 comments

Comments

@jrk
Copy link

jrk commented Dec 21, 2020

I discovered this library looking for a tool to parse Roam EDN exports. (Roam is a Clojure project, so EDN is their most native export format.)

Trying to parse a standard export with this library, I immediately run into:

NotImplementedError: Don't know how to handle tag ImmutableDict(datascript/DB)

Indeed, the Roam export begins with the tag #datascript/DB, but I'm unclear how this is meant to be handled. Am I supposed to register custom types or handlers or something?

@swaroopch
Copy link
Owner

Yes, those are tagged elements, please see tests on how to handle that.

@bfontaine
Copy link
Collaborator

bfontaine commented Dec 21, 2020

You can either use the tag decorator, or use add_tag(<tag>, <function or class>) directly. The parser calls the function (or class) on the tagged element.

A very simple no-op implementation would be:

from edn_parse import tag, add_tag

@tag("datascript/DB")
def identity(m):
    return m

# alternatively:
add_tag("datascript/DB", lambda m: m)

@jrk
Copy link
Author

jrk commented Dec 21, 2020

Excellent, thanks! Closing, with a suggestion to document this more prominently (e.g., in README).

@jrk jrk closed this as completed Dec 21, 2020
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

No branches or pull requests

3 participants