Module Djot.Stream

type t

A parse fed its input in parts. Blocks are returned as the input closes them, and finish gives the source, and with it the document.

val start : ?profile:Profile.t -> ?locs:bool -> ?frontmatter:bool -> unit -> t

With frontmatter, see Frontmatter, a first line of --- is held, and the lines after it, until a closing --- or the end of the input says whether they are frontmatter. Frontmatter gives no block; lines that are not frontmatter give theirs then.

val feed_string : t -> string -> Block.t node list * t

Feed bytes: any part of the input, holding several lines or part of one.

  • returns

    the blocks closed by the lines this completes. Bytes after the last newline are held until their line ends.

val feed_line : t -> string -> Block.t node list * t

feed_line t l is feed_string t (l ^ "\n").

val peek : t -> Block.t node list

held blocks that would be returned if the input ended here.

val finish : t -> Source.t

The source of all the input fed, equal to Source.of_string on its concatenation. Every block returned by a feed, followed by peek, is the parse its document was built from. With locs, Doc.textloc of that document locates the returned blocks.

module Sections : sig ... end

The sections Doc.blocks nests the blocks in, as events over the returned blocks: a heading leaves every open section of its level or deeper and enters its own.