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