typst

package
v2.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 17 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package typst projects composed render manifests into a compilable Typst workspace: a main .typ file, one .typ file per fragment, and inert asset bindings an effectful collector materializes.

Index

Constants

View Source
const MainFile = "main.typ"

MainFile is the workspace-relative entry point of every projection.

View Source
const Target = "typst"

Target is the dispatch target these definitions register under and the backend name the projector answers to.

Variables

View Source
var (
	ErrInvalidManifest      = errors.New("invalid render manifest")
	ErrNestedSection        = errors.New("section fragments must be document roots")
	ErrUnsupportedAsset     = errors.New("unsupported artifact media type")
	ErrUnsupportedComponent = errors.New("component has no typst projection")
)
View Source
var DiagnosticPattern = regexp.MustCompile(`(?m)([^:\n]+\.typ):(\d+):\d+:\s*([^\n]+)`)

DiagnosticPattern matches `typst compile --diagnostic-format short` lines: submatch 1 is the file (root-relative, "/fragments/x.typ"), 2 the line and 3 the severity and message.

Functions

func Catalog

func Catalog() (*component.Catalog, error)

Catalog freezes a catalog holding exactly the Typst definitions.

func DefaultKeys

func DefaultKeys() []component.Key

DefaultKeys are the dispatch keys the projector accepts by default: exactly the keys of Definitions.

func Definitions

func Definitions() ([]component.Definition, error)

Definitions returns the Typst projections of the builtin kinds of pkg/component: text (flow), section (section) and artifact (artifact). Text props are escaped as Typst markup; they are never interpreted.

func Project

func Project(manifest composition.RenderManifest, options Options) (latex.Projection, error)

Project maps composition modes to Typst source boundaries: flow -> #include, root section -> page-isolated #include, artifact -> #image of a bound asset. The result shares latex.Projection's shape so the projection generator and preview pipeline carry it unchanged.

func Register

func Register(builder *component.Builder) error

Register installs every Typst definition into a catalog builder.

Types

type Options

type Options struct {
	// TrustedPreamble is emitted verbatim at the top of main.typ (set and
	// show rules). Callers must not route document content through it.
	TrustedPreamble []byte
	// FocusSections limits the build to these root sections; flow and
	// artifact roots are always kept, as LaTeX's \includeonly does.
	FocusSections []string
	// Supported lists the dispatch keys whose fragments hold Typst markup.
	// Nil selects DefaultKeys. Any other fragment is refused by name.
	Supported []component.Key
}

Options controls trusted document-level Typst and focused section builds.

type Projector

type Projector struct {
	// contains filtered or unexported fields
}

Projector adapts Project to the document engine's projector seam.

func NewProjector

func NewProjector(options Options) *Projector

NewProjector returns a projector that renders every manifest with options; a request contributes only its focus sections.

func (*Projector) ProjectManifest

func (projector *Projector) ProjectManifest(manifest composition.RenderManifest, focusSections []string) (latex.Projection, error)

ProjectManifest satisfies the engine's projector seam.

type UnsupportedComponentError

type UnsupportedComponentError struct {
	ComponentID string
	Key         component.Key
}

UnsupportedComponentError names the component the Typst projector refused and the dispatch key it carried. It matches ErrUnsupportedComponent.

func (*UnsupportedComponentError) Error

func (failure *UnsupportedComponentError) Error() string

func (*UnsupportedComponentError) Is

func (failure *UnsupportedComponentError) Is(target error) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL