(rules: &'static std::thread::LocalKey<RefCell<SpeechRules>>, doc: Document<'m>, mathml: Element, nav_node_id: &'m str)
| 80 | |
| 81 | |
| 82 | fn intent_rules<'m>(rules: &'static std::thread::LocalKey<RefCell<SpeechRules>>, doc: Document<'m>, mathml: Element, nav_node_id: &'m str) -> Result<Element<'m>> { |
| 83 | SpeechRules::update()?; |
| 84 | rules.with(|rules| { |
| 85 | rules.borrow_mut().read_files()?; |
| 86 | let rules = rules.borrow(); |
| 87 | // debug!("speak_rules:\n{}", mml_to_string(&mathml)); |
| 88 | let mut rules_with_context = SpeechRulesWithContext::new(&rules, doc, nav_node_id); |
| 89 | let intent = rules_with_context.match_pattern::<Element<'m>>(mathml) |
| 90 | .chain_err(|| "Pattern match/replacement failure!")?; |
| 91 | if name(&intent) == "TEMP_NAME" { // unneeded extra layer |
| 92 | assert_eq!(intent.children().len(), 1); |
| 93 | return Ok( as_element(intent.children()[0]) ); |
| 94 | } else { |
| 95 | return Ok(intent); |
| 96 | } |
| 97 | }) |
| 98 | } |
| 99 | |
| 100 | /// Speak the MathML |
| 101 | /// If 'nav_node_id' is not an empty string, then the element with that id will have [[...]] around it |
no test coverage detected