ratex_parser/functions/
text.rs1use 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 &["\\text", "\\textrm", "\\textsf", "\\texttt", "\\textnormal",
11 "\\textbf", "\\textit", "\\textmd", "\\textup", "\\textsl", "\\textsc"],
12 "text",
13 1, 0,
14 Some(vec![ArgType::Text]),
15 true, true, true,
18 false, false,
19 handle_text,
20 );
21}
22
23fn handle_text(
24 ctx: &mut FunctionContext,
25 args: Vec<ParseNode>,
26 _opt_args: Vec<Option<ParseNode>>,
27) -> ParseResult<ParseNode> {
28 let body = args.into_iter().next().unwrap();
29 let body_vec = ParseNode::ord_argument(body);
30
31 let font = Some(ctx.func_name.clone());
32
33 Ok(ParseNode::Text {
34 mode: ctx.parser.mode,
35 body: body_vec,
36 font,
37 loc: None,
38 })
39}