Skip to main content

Module builder

Module builder 

Source
Expand description

ConstructorBuilder — the shared lowering for DefConstructor.

Both binding front-ends target this one builder, so they cannot drift:

  • the compile-time DefConstructor! macro (latexml_engine), and
  • the runtime Rhai script layer (latexml_contrib::script_bindings).

It is front-end-agnostic: it takes already-native values and closures, so it lives in latexml_core and pulls in neither the macro machinery nor Rhai.

Two kinds of options, by how much can be shared:

  • Scalar options (mode, bounded, …) go through one generic ConstructorBuilder::set_option — the key→field mapping lives in exactly one place, so adding a scalar option updates both front-ends at once.
  • Closure options (afterDigest, …) have typed setters: the field and install are shared, while the closure itself is produced by whichever front-end (a macro $body:block, or a Rhai trampoline).

Structs§

ConstructorBuilder
Accumulates a constructor definition and installs it via def_constructor.
EnvironmentBuilder
Accumulates an environment definition and installs it via def_environment — the environment analog of ConstructorBuilder, sharing the same option machinery. The prototype is the DefEnvironment! shape: "{name}" or "{name}{}…" (env name in braces, then the parameter list).

Enums§

OptionValue
A scalar option value handed to ConstructorBuilder::set_option. Both front-ends produce these (the macro from a literal, Rhai from a Dynamic), so the key→field switch is single-source.