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)
| 245 | /// Get the node associated with 'id' |
| 246 | /// This can be called on an intent tree -- it does not make use of is_leaf() |
| 247 | fn 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 |
| 265 | pub fn context_get_variable<'c>(context: &Context<'c>, var_name: &str, mathml: Element<'c>) -> Result<(Option<String>, Option<f64>)> { |
no outgoing calls
no test coverage detected