Skip to main content

ratex_parser/functions/
hbox.rs

1use std::collections::HashMap;
2
3use crate::error::ParseResult;
4use crate::functions::{define_function_full, ArgType, FunctionContext, FunctionSpec};
5use crate::parse_node::ParseNode;
6
7pub fn register(map: &mut HashMap<&'static str, FunctionSpec>) {
8    define_function_full(
9        map,
10        &["\\hbox"],
11        "hbox",
12        1, 0,
13        Some(vec![ArgType::Text]),
14        false,
15        true, true,
16        false, true,
17        handle_hbox,
18    );
19}
20
21fn handle_hbox(
22    ctx: &mut FunctionContext,
23    args: Vec<ParseNode>,
24    _opt_args: Vec<Option<ParseNode>>,
25) -> ParseResult<ParseNode> {
26    Ok(ParseNode::HBox {
27        mode: ctx.parser.mode,
28        body: ParseNode::ord_argument(args.into_iter().next().unwrap()),
29        loc: None,
30    })
31}