Skip to main content

ratex_parser/functions/
raisebox.rs

1use std::collections::HashMap;
2
3use crate::error::{ParseError, 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        &["\\raisebox"],
11        "raisebox",
12        2,
13        0,
14        Some(vec![ArgType::Size, ArgType::HBox]),
15        false,
16        true,
17        true,
18        false,
19        false,
20        handle_raisebox,
21    );
22}
23
24fn handle_raisebox(
25    ctx: &mut FunctionContext,
26    args: Vec<ParseNode>,
27    _opt_args: Vec<Option<ParseNode>>,
28) -> ParseResult<ParseNode> {
29    let mut args = args.into_iter();
30    let dy = match args.next() {
31        Some(ParseNode::Size { value, .. }) => value,
32        _ => return Err(ParseError::msg("Expected size for \\raisebox")),
33    };
34    let body = args.next().unwrap();
35
36    Ok(ParseNode::RaiseBox {
37        mode: ctx.parser.mode,
38        dy,
39        body: Box::new(body),
40        loc: None,
41    })
42}