MCPcopy Create free account
hub / github.com/Noumena-Network/code / wrap_with_width

Function wrap_with_width

native/markdown-renderer-napi/src/lib.rs:16–31  ·  view source on GitHub ↗
(code: &str, width: usize)

Source from the content-addressed store, hash-verified

14}
15
16fn wrap_with_width(code: &str, width: usize) -> Vec<String> {
17 let width = width.max(1);
18 let opts = WrapOptions::new(width).word_splitter(WordSplitter::NoHyphenation);
19 code.lines()
20 .flat_map(|line| {
21 if line.is_empty() {
22 vec![String::new()]
23 } else {
24 wrap(line, &opts)
25 .into_iter()
26 .map(|cow| cow.to_string())
27 .collect::<Vec<_>>()
28 }
29 })
30 .collect()
31}
32
33#[cfg(test)]
34mod tests {

Callers 3

render_fenced_codeFunction · 0.85
keeps_empty_linesFunction · 0.85

Calls 2

wrapFunction · 0.85
maxMethod · 0.80

Tested by 2

keeps_empty_linesFunction · 0.68