MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / html_escape

Function html_escape

atomic-core/src/diff/inline.rs:558–571  ·  view source on GitHub ↗

Escape HTML special characters.

(text: &str)

Source from the content-addressed store, hash-verified

556
557/// Escape HTML special characters.
558fn 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("&lt;"),
564 '>' => result.push_str("&gt;"),
565 '"' => result.push_str("&quot;"),
566 '\'' => result.push_str("&#39;"),
567 _ => result.push(c),
568 }
569 }
570 result
571}
572
573/// Compute an inline diff between two lines.
574///

Callers 1

render_with_htmlMethod · 0.85

Calls 2

lenMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected