Escape HTML special characters.
(text: &str)
| 556 | |
| 557 | /// Escape HTML special characters. |
| 558 | fn html_escape(text: &str) -> String { |
| 559 | let mut result = String::with_capacity(text.len()); |
| 560 | for c in text.chars() { |
| 561 | match c { |
| 562 | '&' => result.push_str("&"), |
| 563 | '<' => result.push_str("<"), |
| 564 | '>' => result.push_str(">"), |
| 565 | '"' => result.push_str("""), |
| 566 | '\'' => result.push_str("'"), |
| 567 | _ => result.push(c), |
| 568 | } |
| 569 | } |
| 570 | result |
| 571 | } |
| 572 | |
| 573 | /// Compute an inline diff between two lines. |
| 574 | /// |
no test coverage detected