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

Function emit

libatomic/src/review/html.rs:412–430  ·  view source on GitHub ↗
(document: Value, fallback: &str)

Source from the content-addressed store, hash-verified

410}
411
412fn emit(document: Value, fallback: &str) -> CliResult<String> {
413 let data = serde_json::to_string(&document)
414 .map_err(|error| CliError::Internal(error.into()))?
415 .replace('<', "\\u003c")
416 .replace('>', "\\u003e")
417 .replace('&', "\\u0026")
418 .replace('\u{2028}', "\\u2028")
419 .replace('\u{2029}', "\\u2029");
420 let nonce = uuid::Uuid::new_v4().simple().to_string();
421 Ok(format!(
422 include_str!("viewer.html"),
423 nonce = nonce,
424 logo = data_encoding::BASE64.encode(include_bytes!("assets/atomic-logo.png")),
425 css = include_str!("viewer.css"),
426 script = include_str!("viewer.js"),
427 data = data,
428 fallback = escape(fallback)
429 ))
430}
431
432#[cfg(test)]
433mod tests {

Calls 2

simpleMethod · 0.80
replaceMethod · 0.45