ratex_parser/functions/
overline.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 &["\\overline"],
11 "overline",
12 1, 0, None,
13 false, false, true, false, false,
14 handle_overline,
15 );
16
17 define_function_full(
18 map,
19 &["\\underline"],
20 "underline",
21 1, 0, None,
22 false,
23 true, true,
25 false, false,
26 handle_underline,
27 );
28}
29
30fn handle_overline(
31 ctx: &mut FunctionContext,
32 args: Vec<ParseNode>,
33 _opt_args: Vec<Option<ParseNode>>,
34) -> ParseResult<ParseNode> {
35 Ok(ParseNode::Overline {
36 mode: ctx.parser.mode,
37 body: Box::new(args.into_iter().next().unwrap()),
38 loc: None,
39 })
40}
41
42fn handle_underline(
43 ctx: &mut FunctionContext,
44 args: Vec<ParseNode>,
45 _opt_args: Vec<Option<ParseNode>>,
46) -> ParseResult<ParseNode> {
47 Ok(ParseNode::Underline {
48 mode: ctx.parser.mode,
49 body: Box::new(args.into_iter().next().unwrap()),
50 loc: None,
51 })
52}