MCPcopy Create free account
hub / github.com/daisy/MathCAT / get_node_by_id

Function get_node_by_id

src/navigate.rs:247–262  ·  view source on GitHub ↗

Get the node associated with 'id' This can be called on an intent tree -- it does not make use of is_leaf()

(mathml: Element<'a>, id: &str)

Source from the content-addressed store, hash-verified

245/// Get the node associated with 'id'
246/// This can be called on an intent tree -- it does not make use of is_leaf()
247fn get_node_by_id<'a>(mathml: Element<'a>, id: &str) -> Option<Element<'a>> {
248 if let Some(mathml_id) = mathml.attribute_value("id") {
249 if mathml_id == id {
250 return Some(mathml);
251 }
252 }
253
254 for child in mathml.children() {
255 if let Some(child) = child.element() {
256 if let Some(found) = get_node_by_id(child, id) {
257 return Some(found);
258 }
259 }
260 }
261 return None;
262}
263
264// FIX: think of a better place to put this, and maybe a better interface
265pub fn context_get_variable<'c>(context: &Context<'c>, var_name: &str, mathml: Element<'c>) -> Result<(Option<String>, Option<f64>)> {

Callers 4

get_navigation_mathmlMethod · 0.85
get_start_nodeFunction · 0.85
apply_navigation_rulesFunction · 0.85
speakFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected