MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / renderInline

Function renderInline

src/cli/render/assistant-message.tsx:84–98  ·  view source on GitHub ↗
(s: string)

Source from the content-addressed store, hash-verified

82/** Render a prose string with inline **bold** and `code` styled. Preserves all
83 * visible characters (only the markers themselves are dropped). */
84export function renderInline(s: string): React.ReactNode[] {
85 const out: React.ReactNode[] = [];
86 const re = /(\*\*([^*]+?)\*\*|`([^`]+?)`)/g;
87 let last = 0;
88 let m: RegExpExecArray | null;
89 let key = 0;
90 while ((m = re.exec(s)) !== null) {
91 if (m.index > last) out.push(<Text key={key++}>{s.slice(last, m.index)}</Text>);
92 if (m[2] !== undefined) out.push(<Text key={key++} bold>{m[2]}</Text>);
93 else if (m[3] !== undefined) out.push(<Text key={key++} color="cyan">{m[3]}</Text>);
94 last = re.lastIndex;
95 }
96 if (last < s.length) out.push(<Text key={key++}>{s.slice(last)}</Text>);
97 return out.length ? out : [<Text key={0}>{s}</Text>];
98}
99
100function ProseLine({ line }: { line: string }): React.ReactElement {
101 // Headings — clear hierarchy by level.

Callers 2

ProseLineFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected