gather up all the contents of the element and return them with a leading space
(html: Element)
| 505 | |
| 506 | /// gather up all the contents of the element and return them with a leading space |
| 507 | fn gather_text(html: Element) -> String { |
| 508 | let mut text = "".to_string(); // since we are throwing out the element tag, add a space between the contents |
| 509 | for child in html.children() { |
| 510 | match child { |
| 511 | ChildOfElement::Element(child) => { |
| 512 | text = text + " " + gather_text(child).trim_matches(WHITESPACE); |
| 513 | }, |
| 514 | ChildOfElement::Text(t) => text += t.text(), |
| 515 | _ => (), |
| 516 | } |
| 517 | } |
| 518 | return text; |
| 519 | } |
| 520 | } |
| 521 | } |
| 522 |