Files
grok-cli/src/ui/utils/markdown-renderer.tsx
T
Thomas MetcalfeandCursor Agent bd78e9e845 fix: re-enable vibekit by resolving runtime crash when using grok cli (#77)
* chore: update react and remove ink-markdown

* feat: add marked-terminal

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-09-12 15:57:43 +02:00

23 lines
761 B
TypeScript

import React from 'react';
import { Text } from 'ink';
import { marked } from 'marked';
import TerminalRenderer from 'marked-terminal';
// Configure marked to use the terminal renderer with default settings
marked.setOptions({
renderer: new (TerminalRenderer as any)()
});
export function MarkdownRenderer({ content }: { content: string }) {
try {
// Use marked.parse for synchronous parsing
const result = marked.parse(content);
// Handle both sync and async results
const rendered = typeof result === 'string' ? result : content;
return <Text>{rendered}</Text>;
} catch (error) {
// Fallback to plain text if markdown parsing fails
console.error('Markdown rendering error:', error);
return <Text>{content}</Text>;
}
}