pub struct EnvSpec {
pub node_type: NodeType,
pub num_args: usize,
pub arg_types: Option<Vec<ArgType>>,
pub allowed_in_text: bool,
pub num_optional_args: usize,
pub handler: EnvHandler,
}
Expand description
Processed environment specification used during LaTeX parsing.
This struct represents the final, resolved configuration for an environment after processing the definition specification. It contains all necessary information for the parser to handle the environment correctly, with defaults applied and validation performed.
§See Also
EnvHandler
: The handler function for processing the environmentcrate::parser
: Parser that uses these specifications
Fields§
§node_type: NodeType
Node type that this environment produces.
Specifies the type of parse node that will be created when this environment is successfully parsed. This determines how the environment is represented internally and rendered.
§Examples
NodeType::Environment
: Generic environmentNodeType::Matrix
: Matrix-specific environment
num_args: usize
Number of required arguments for this environment.
The exact count of mandatory arguments that must be provided.
This is resolved from the optional num_args
in EnvProps
.
§Examples
0
: No required arguments (content parsed internally)2
: Exactly two required arguments
arg_types: Option<Vec<ArgType>>
Argument types for each required argument.
Specifies the expected type of each argument. The vector length
must match num_args
. This is resolved from the optional
arg_types
in EnvProps
.
§See Also
ArgType
: Available argument types
allowed_in_text: bool
Whether this environment is allowed in text mode.
Controls whether the environment can be used in regular text
contexts or only within mathematical expressions. This is
resolved from the optional allowed_in_text
in EnvProps
.
§Examples
true
: Can be used in both text and math modesfalse
: Math mode only (most mathematical environments)
num_optional_args: usize
Number of optional arguments this environment accepts.
The exact count of optional arguments that can be provided.
This is resolved from the optional num_optional_args
in EnvProps
.
§Examples
0
: No optional arguments1
: One optional argument allowed
handler: EnvHandler
The handler function that processes this environment.
This function is called during parsing to validate arguments and create the appropriate parse node. It encapsulates the core logic for the environment type.
§See Also
EnvHandler
: The function signature
Trait Implementations§
Source§impl Default for EnvSpec
Provides a basic default environment specification.
impl Default for EnvSpec
Provides a basic default environment specification.
The default implementation creates a minimal environment spec that can be used as a starting point. The default handler returns an error, so this should be customized with a proper handler for actual use.
§Warning
The default handler will always return an error. You must provide a
proper EnvHandler
implementation for the environment to function.