MCPcopy Create free account
hub / github.com/cursor/cookbook / parseInlineMarkdown

Function parseInlineMarkdown

sdk/coding-agent-cli/src/tui/App.tsx:790–822  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

788}
789
790function parseInlineMarkdown(value: string): TranscriptPart[] {
791 const parts: TranscriptPart[] = []
792 const pattern = /(`[^`]+`|\[([^\]]+)\]\(([^)]+)\)|(https?:\/\/\S+))/g
793 let lastIndex = 0
794 let match: RegExpExecArray | null
795
796 while ((match = pattern.exec(value))) {
797 if (match.index > lastIndex) {
798 parts.push({ text: value.slice(lastIndex, match.index) })
799 }
800
801 const token = match[0]
802 if (token.startsWith("`")) {
803 parts.push({
804 text: token.slice(1, -1),
805 color: "yellow",
806 })
807 } else if (match[2] && match[3]) {
808 parts.push({ text: match[2], color: "blue" })
809 parts.push({ text: ` (${match[3]})`, color: "gray", dimColor: true })
810 } else {
811 parts.push({ text: token, color: "blue" })
812 }
813
814 lastIndex = match.index + token.length
815 }
816
817 if (lastIndex < value.length) {
818 parts.push({ text: value.slice(lastIndex) })
819 }
820
821 return parts.length > 0 ? parts : [{ text: "" }]
822}
823
824function appendAssistantDelta(
825 items: TranscriptEntry[],

Callers 1

renderMarkdownLinesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected