Closed jrk closed 3 years ago
Yes, those are tagged elements, please see tests on how to handle that.
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)
Excellent, thanks! Closing, with a suggestion to document this more prominently (e.g., in README).
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:
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?