(rules_with_context: &'r mut SpeechRulesWithContext<'c,'s,'m>, mathml: Element<'c>, nav_node_id: String, full_read: bool)
| 500 | } |
| 501 | |
| 502 | fn speak<'r, 'c, 's:'c, 'm:'c>(rules_with_context: &'r mut SpeechRulesWithContext<'c,'s,'m>, mathml: Element<'c>, nav_node_id: String, full_read: bool) -> Result<String> { |
| 503 | if full_read { |
| 504 | let intent = crate::speech::intent_from_mathml(mathml, rules_with_context.get_document())?; |
| 505 | debug!("intent: {}", mml_to_string(&intent)); |
| 506 | |
| 507 | // In something like x^3, we might be looking for the '3', but it will be "cubed", so we don't find it. |
| 508 | // Or we might be on a "(" surrounding a matrix and that isn't part of the intent |
| 509 | // We are probably safer in terms of getting the same speech if we retry intent starting at the nav node, |
| 510 | // but the node to speech is almost certainly trivial. |
| 511 | // By speaking the non-intent tree, we are certain to speech on the next try |
| 512 | if get_node_by_id(intent, &nav_node_id).is_some() { |
| 513 | match crate::speech::speak_mathml(intent, &nav_node_id) { |
| 514 | Ok(speech) => return Ok(speech), |
| 515 | Err(e) => { |
| 516 | if e.to_string() != crate::speech::NAV_NODE_SPEECH_NOT_FOUND { |
| 517 | return Err(e); |
| 518 | } |
| 519 | // else could be something like '3' in 'x^3' ("cubed") |
| 520 | }, |
| 521 | } |
| 522 | } |
| 523 | return crate::speech::speak_mathml(mathml, &nav_node_id); |
| 524 | } else { |
| 525 | return crate::speech::overview_mathml(mathml, &nav_node_id); |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | |
| 530 | // MathPlayer's interface mentions these, so we keep them. |
no test coverage detected