Djot.DocA parsed document: its blocks, and the footnotes and references they define.
A document does not keep the text it was parsed from. To edit a document's text and parse only what the edit affects, use Source.
Parses a djot text.
Each heading gets an identifier and is wrapped, with the blocks under it, in a Block.t.Section. Footnote and reference definitions stay in the blocks, and are also collected by label in footnotes and references.
val frontmatter : t -> Frontmatter.t optionThe frontmatter the text started with. None for a document made from blocks.
val make :
?profile:Profile.t ->
?frontmatter:Frontmatter.t ->
Block.t node list ->
tThe document these blocks make: headings get identifiers and sections, and footnotes and references are collected, as of_string does for a text.
A Block.t.Section among the blocks is replaced by its blocks, its attributes going to the heading it opens with, so the blocks of a document can be given back. An identifier already on a heading or section is kept as a written one, also when it is in auto_identifiers of the document the blocks came from; give it source_blocks to have those derived again.
The document has no positions: textloc gives Textloc.none.
val with_frontmatter : Frontmatter.t option -> t -> tThe document with this frontmatter, or none. Its blocks keep their positions, which are in the text the document was parsed from.
The document as djot source, in the syntax of the profile it was parsed with. An identifier in auto_identifiers is not written.
With `Safe or `Checked, parsing the result with that profile gives the same tree, up to source positions, except that:
| in a table cell's text splits the cell.The round trip is proved in Rocq for a fragment of documents written with `Safe; beyond it this is tested, not proved.
With `Naive the result need not parse back to the same tree; see style.
frontmatter is written first, its text as it was.
blocks without the identifiers in auto_identifiers, as they were written. Each block is the one at the same place in blocks, with only those identifiers removed. make given these blocks, the profile and the frontmatter gives a document with the same to_string and auto_identifiers.
The footnotes: one entry per label, with the blocks of its definition as they are in blocks. A definition written inside another is in that one's blocks and has an entry of its own.
Two labels are the same when they are equal once each run of whitespace is replaced by one space, so [^a b] and [^a b] are one footnote and [^a] and [^A] are two. When a label is defined more than once, the entry holds the last definition; every definition is in blocks.
The blocks of the footnote with this label, compared as in footnotes.
Explicit reference definitions: label, destination, attributes.
One reference per heading: the heading's text as label, and its identifier after a # as destination.
val auto_identifiers : t -> string listThe identifiers derived from a heading's text, in document order; an identifier a heading was written with is not listed. Going through the headings and sections in document order, the first one with the next listed identifier is the one it was derived for.
A label's destination, from an explicit definition or else from a heading.
Textloc.none unless the document was parsed with ~locs:true and the node came from that parse. A list item spans from its marker to its last content, a table row its line, a cell from its leading |, a caption from its ^, a footnote definition from its [^].
type syntax = Kernel.Ast.syntax_role =