MCPcopy Create free account
hub / github.com/base/base / markdown_code

Method markdown_code

acceptance/src/report.rs:605–620  ·  view source on GitHub ↗

Renders untrusted text as portable inline code without Markdown delimiter ambiguity.

(value: &str)

Source from the content-addressed store, hash-verified

603
604 /// Renders untrusted text as portable inline code without Markdown delimiter ambiguity.
605 pub fn markdown_code(value: &str) -> String {
606 let delimiter = "`".repeat(value.split(|c| c != '`').map(str::len).max().unwrap_or(0) + 1);
607 let text: String = value
608 .chars()
609 .map(|c| {
610 if c.is_whitespace() {
611 ' '
612 } else if c.is_control() {
613 '�'
614 } else {
615 c
616 }
617 })
618 .collect();
619 format!("{delimiter} {text} {delimiter}")
620 }
621
622 /// Validates a bounded portable record identifier.
623 pub fn valid_id(kind: &str, value: &str) -> Result<()> {

Callers

nothing calls this directly

Calls 3

maxMethod · 0.80
splitMethod · 0.45
collectMethod · 0.45

Tested by

no test coverage detected