latexml_core/binding/def/
options.rs1pub const MACRO_OPTIONS: &[&str] = &[
7 "scope",
8 "locked",
9 "mathactive",
10 "protected",
11 "robust",
12 "outer",
13 "long",
14 "nopackParameters",
15];
16
17pub const PARAMETER_OPTIONS: &[&str] = &[
19 "nargs",
20 "reversion",
21 "optional",
22 "novalue",
23 "beforeDigest",
24 "afterDigest",
25 "semiverbatim",
26 "undigested",
27];
28
29pub const REGISTER_OPTIONS: &[&str] = &["readonly", "getter", "setter", "address", "allocate"];
31
32pub const CONDITIONAL_OPTIONS: &[&str] = &["scope", "locked", "skipper"];
34
35pub const PRIMITIVE_OPTIONS: &[&str] = &[
37 "isPrefix",
38 "scope",
39 "font",
40 "mode",
41 "enterHorizontal",
42 "leaveHorizontal",
43 "requireMath",
44 "forbidMath",
45 "beforeDigest",
46 "afterDigest",
47 "bounded",
48 "locked",
49 "alias",
50 "robust",
51 "outer",
52 "long",
53];
54
55pub const CONSTRUCTOR_OPTIONS: &[&str] = &[
57 "mode",
58 "requireMath",
59 "forbidMath",
60 "font",
61 "enterHorizontal",
62 "leaveHorizontal",
63 "alias",
64 "reversion",
65 "sizer",
66 "properties",
67 "nargs",
68 "attributeForm",
69 "beforeDigest",
70 "afterDigest",
71 "beforeConstruct",
72 "afterConstruct",
73 "captureBody",
74 "scope",
75 "bounded",
76 "locked",
77 "outer",
78 "long",
79 "robust",
80];
81
82pub const ENVIRONMENT_OPTIONS: &[&str] = &[
84 "mode",
85 "requireMath",
86 "forbidMath",
87 "enterHorizontal",
88 "leaveHorizontal",
89 "properties",
90 "nargs",
91 "font",
92 "beforeDigest",
93 "afterDigest",
94 "afterDigestBegin",
95 "beforeDigestEnd",
96 "afterDigestBody",
97 "beforeConstruct",
98 "afterConstruct",
99 "reversion",
100 "sizer",
101 "scope",
102 "locked",
103 "attributeForm",
104];
105
106pub const MATH_OPTIONS: &[&str] = &[
108 "name",
109 "meaning",
110 "omcd",
111 "reversion",
112 "sizer",
113 "alias",
114 "role",
115 "operator_role",
116 "reorder",
117 "dual",
118 "decl_id",
119 "mathstyle",
120 "font",
121 "scriptpos",
122 "operator_scriptpos",
123 "stretchy",
124 "operator_stretchy",
125 "lpadding",
126 "rpadding",
127 "beforeDigest",
128 "afterDigest",
129 "scope",
130 "nogroup",
131 "locked",
132 "protected",
133 "robust",
134 "revert_as",
135 "hide_content_reversion",
136];
137
138pub fn check_options<'a>(
142 operation: &str,
143 allowed: &[&str],
144 keys: impl IntoIterator<Item = &'a str>,
145) -> crate::common::error::Result<bool> {
146 let bad: Vec<&str> = keys.into_iter().filter(|k| !allowed.contains(k)).collect();
147 if bad.is_empty() {
148 return Ok(true);
149 }
150 crate::Error!(
151 "misdefined",
152 operation,
153 format!("{operation} does not accept options:{}", bad.join(", "))
154 );
155 Ok(false)
156}
157
158pub fn unsupported_option(operation: &str, key: &str) {
160 crate::Warn!(
161 "unsupported",
162 operation,
163 format!("option {key} is not supported yet; ignored")
164 );
165}