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

Method render_with_html

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

Internal helper to render content with HTML.

(&self, content: &[u8], hunks: &[ChangeHunk], class: &str)

Source from the content-addressed store, hash-verified

533
534 /// Internal helper to render content with HTML.
535 fn render_with_html(&self, content: &[u8], hunks: &[ChangeHunk], class: &str) -> String {
536 let mut result = String::new();
537
538 for hunk in hunks {
539 let text = String::from_utf8_lossy(hunk.extract(content));
540 // Escape HTML entities
541 let escaped = html_escape(&text);
542
543 if hunk.is_change() {
544 result.push_str(&format!(
545 "<span class=\"diff-{}\">{}</span>",
546 class, escaped
547 ));
548 } else {
549 result.push_str(&escaped);
550 }
551 }
552
553 result
554 }
555}
556
557/// Escape HTML special characters.

Callers 2

render_old_htmlMethod · 0.80
render_new_htmlMethod · 0.80

Calls 3

html_escapeFunction · 0.85
extractMethod · 0.45
is_changeMethod · 0.45

Tested by

no test coverage detected