(&'r mut self, nodes: Vec<Node<'c>>, mathml: Element<'c>)
| 2402 | } |
| 2403 | |
| 2404 | fn replace_nodes_string(&'r mut self, nodes: Vec<Node<'c>>, mathml: Element<'c>) -> Result<String> { |
| 2405 | // debug!("replace_nodes: working on {} nodes", nodes.len()); |
| 2406 | let mut result = String::with_capacity(3*nodes.len()); // guess (2 chars/node + space) |
| 2407 | let mut first_time = true; |
| 2408 | for node in nodes { |
| 2409 | if first_time { |
| 2410 | first_time = false; |
| 2411 | } else { |
| 2412 | result.push(' '); |
| 2413 | }; |
| 2414 | let matched = match node { |
| 2415 | Node::Element(n) => self.match_pattern::<String>(n)?, |
| 2416 | Node::Text(t) => self.replace_chars(t.text(), mathml)?, |
| 2417 | Node::Attribute(attr) => self.replace_chars(attr.value(), mathml)?, |
| 2418 | _ => bail!("replace_nodes: found unexpected node type!!!"), |
| 2419 | }; |
| 2420 | result += &matched; |
| 2421 | } |
| 2422 | return Ok( result ); |
| 2423 | } |
| 2424 | |
| 2425 | /// Lookup unicode "pronunciation" of char. |
| 2426 | /// Note: TTS is not supported here (not needed and a little less efficient) |
no test coverage detected