| 104 | } |
| 105 | |
| 106 | fn dehtml_cleanup(mut text: String) -> String { |
| 107 | text.retain(|c| c != '\r'); |
| 108 | let lines = text.trim().split('\n'); |
| 109 | let mut text = String::new(); |
| 110 | let mut linebreak = false; |
| 111 | for line in lines { |
| 112 | if line.chars().all(char::is_whitespace) { |
| 113 | linebreak = true; |
| 114 | } else { |
| 115 | if !text.is_empty() { |
| 116 | text += "\n"; |
| 117 | if linebreak { |
| 118 | text += "\n"; |
| 119 | } |
| 120 | } |
| 121 | text += line.trim_end(); |
| 122 | linebreak = false; |
| 123 | } |
| 124 | } |
| 125 | text |
| 126 | } |
| 127 | |
| 128 | fn dehtml_quick_xml(buf: &str) -> (String, String) { |
| 129 | let buf = buf.trim().trim_start_matches("<!doctype html>"); |