Djot_jsonDjot trees as JSON, in the format of djot.js's AST.
A node is an object with its "tag", the members of that tag, "attributes" when it has any and "pos" when it has a position. Tags and members are the ones djot.js writes, so its ast.ts is the reference for them.
Members and tags djot.js does not have:
"plain" on a heading and on a keyed block: the text of the heading or of the label, as Djot.Inline.to_plain_text gives it;"tight" on a definition list;"name" on a div or span that has one;"ext_wikilink", "ext_keyed" and "ext_callout", with the members of Djot.Inline.t.Ext_wikilink, Djot.Block.t.Ext_keyed and Djot.Block.t.Ext_callout;"frontmatter" on a document that has one: the fields of Djot.Frontmatter as a JSON object, a number that is not finite as null.Where the tree does not hold what djot.js writes:
"str", as the character they render to; there is no "smart_punctuation" node;"pos" has the range of Djot.Doc.textloc, and its columns and offsets count bytes where djot.js counts UTF-16 code units.val block : Djot.Block.t Djot.node Jsont.tA Djot.Block.t.FootnoteDef is a "footnote" and a Djot.Block.t.RefDef a "reference", each where it is in the tree. A Djot.Block.t.AttrBlock is a "block_attributes", which djot.js's AST does not have.
An identifier is in "attributes" whether it was written or derived: a tree does not say which. Only of_doc writes "autoAttributes".
Decoding skips unknown members. It reads "plain", "pos" and a row's "head" and drops them, and puts an identifier under "autoAttributes" first among the attributes. So a decoded node has no position, and decoding what was encoded gives the same tree up to positions.
val inline : Djot.Inline.t Djot.node Jsont.tval of_doc : Djot.Doc.t -> Jsont.jsonThe "doc" object: frontmatter when there is one, references, autoReferences and footnotes by label, then the blocks, with the definitions left out as djot.js does. A footnote has the attributes of its definition. An identifier in Djot.Doc.auto_identifiers is under "autoAttributes", as in djot.js. Nodes have a "pos" when the document was parsed with ~locs:true.
val to_string : ?format:Jsont.format -> Djot.Doc.t -> stringof_doc as JSON text.
val to_ast_string : Djot.Doc.t -> stringof_doc in the indented form djot.js prints with -t ast: one node per line with its position, members and attributes, children indented under it, then the references and the footnotes.
val to_doc :
?profile:Djot.Profile.t ->
Jsont.json ->
(Djot.Doc.t, string) Stdlib.resultThe document a "doc" object describes: Djot.Doc.make of its "children", then its "references", then its "footnotes". An identifier under "autoAttributes" is left out and derived again. "autoReferences" is not read.
The JSON does not say where a definition stood, and has one definition per label. So for a document d, to_doc (of_doc d) has the definitions after the other blocks, without those an entry of the same label replaced, and no positions. Its HTML is that of d.
"frontmatter" is read with Djot.Frontmatter.make, so the fields come back and the YAML text they were written as does not. It is an error where make raises.
val of_string :
?file:string ->
?profile:Djot.Profile.t ->
string ->
(Djot.Doc.t, string) Stdlib.resultto_doc of JSON text.