Closed matklad closed 1 year ago
That's a good idea, and I don't think this would be too difficult. However, I'm reluctant to make this library depend on a json library -- right now it has no dependencies. One option would be an optional module that consumes the output of to_ast
and produces json. Or maybe I can just write the necessary json-generating code without using a library.
Yeah, I don't think a library is required to emit json, we can just push stuff to string, the same what we do for HTML (I think?)
Very much appreciate the zero-dependency nature of the reference impl!
I think this is mostly done now, via -a -j
. Most of discussion here happened in #60 :)
I've added this to the live sandbox, too
Problem: I'd love to experiment with djot, but I don't know lua, and would rather use a language I am already familiar with (Rust or TypeScript).
Proposed solution: add
djot -a -j
to output AST in some JSON format which then could be easily consumed by other programs.I think I probably can get something like this via
pandoc
, but I'd rather avoid adding one more tool to the pipeline.Yeah, the appropriate pandoc spell is
pandoc -f djot-reader.lua -t json example.djot
. There's another drawback with that approach: today's pandocjson
output is a rather low-level encoding of Haskell data structures, it's not something you can justJSON.parse
in javascript and get a natural API. I think there's some benefit to defining a more first-class JSON AST encoding for djot.