ratex_parser/functions/
mathchoice.rs1use std::collections::HashMap;
2
3use crate::error::ParseResult;
4use crate::functions::{define_function_full, FunctionContext, FunctionSpec};
5use crate::parse_node::ParseNode;
6
7pub fn register(map: &mut HashMap<&'static str, FunctionSpec>) {
8 define_function_full(
9 map,
10 &["\\mathchoice"],
11 "mathchoice",
12 4,
13 0,
14 None,
15 false,
16 false,
17 true,
18 false,
19 true,
20 handle_mathchoice,
21 );
22}
23
24fn handle_mathchoice(
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 display = ParseNode::ord_argument(args.next().unwrap());
31 let text = ParseNode::ord_argument(args.next().unwrap());
32 let script = ParseNode::ord_argument(args.next().unwrap());
33 let scriptscript = ParseNode::ord_argument(args.next().unwrap());
34
35 Ok(ParseNode::MathChoice {
36 mode: ctx.parser.mode,
37 display,
38 text,
39 script,
40 scriptscript,
41 loc: None,
42 })
43}