MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / renderBlock

Function renderBlock

src/common/terminal.ts:31–61  ·  view source on GitHub ↗
(block: StyledBlock)

Source from the content-addressed store, hash-verified

29 }
30
31 renderBlock(block: StyledBlock): string {
32 const content =
33 'spans' in block
34 ? this.renderSpans(block.spans)
35 : block.blocks.map((b) => this.renderBlock(b)).join('\n');
36
37 if (block.tag === 'paragraph')
38 return `\n${wrapAnsiString(content, this.width).join('\n')}\n\n`;
39
40 if (block.tag === 'blockquote') {
41 const lines = wrapAnsiString(content, (this.width ?? 40) - 4);
42 return lines.map((line) => `> ${line}`).join('\n');
43 }
44
45 if (block.tag === 'note') {
46 const lines = wrapAnsiString(content, (this.width ?? 40) - 3);
47 return lines.map((line) => `| ${line}`).join('\n');
48 }
49
50 if (block.tag === 'warning') {
51 const lines = wrapAnsiString(content, (this.width ?? 40) - 3);
52 return lines.map((line) => `!! ${line}`).join('\n');
53 }
54
55 if (block.tag === 'error') {
56 const lines = wrapAnsiString(content, (this.width ?? 40) - 3);
57 return lines.map((line) => `XX ${line}`).join('\n');
58 }
59
60 return content;
61 }
62
63 abstract renderSpan(span: StyledSpan): string;
64

Callers

nothing calls this directly

Calls 4

wrapAnsiStringFunction · 0.85
renderSpansMethod · 0.80
renderBlockMethod · 0.80
mapMethod · 0.65

Tested by

no test coverage detected