Guidedog 手册 0.2.0
语言
本页内容
Guidedog / 文档 0.2.0

render/typst

Package typst_render encodes a validated Guidedoc document as one Typst source file.

The output is a fixed, trusted preamble of gd- helper definitions followed by the body. Source text never becomes executable Typst: markup text escapes every ASCII punctuation character, and code, URLs, labels, and paths are string literals. Working memory comes only from the render context’s scratch; output goes only through the emitter, so the Measure and Write runs produce identical bytes.

Procedures

typst.emit_preamble :: proc(e: ^gd.Emitter)

emit_preamble writes the helper definitions every body relies on. A host composing a book from body-only chapters writes it once, before the chapters. The text is a constant: it cannot fail, and the emitter counts what does not fit.

typst.render :: proc(ctx: ^gd.Render_Context) -> gd.Status

render writes ctx.view as Typst source through ctx.out: the preamble, page settings, and body when ctx.options.standalone, else the body alone (see emit_preamble). It borrows the context for the call and keeps nothing but scratch taken from ctx, which the caller’s scratch mark releases. Problems go to ctx.reports; the result is .Ok, the status of the first error (raw content the policy refuses, nesting past the limits), or .Capacity when scratch cannot hold the per-node marks.

typst.renderer :: proc() -> gd.Renderer

renderer returns the “typst” renderer descriptor, for a gd.Registry. It is a value with no state: registering it twice or copying it is harmless.

Constants

typst.CONFORMANCE :: gd.Conformance.Partial
typst.VERSION :: "0.1.1"