UNPKG

pyb-ts

Version:

PYB-CLI - Minimal AI Agent with multi-model support and CLI interface

31 lines (30 loc) 1.02 kB
import { highlight, supportsLanguage } from "cli-highlight"; import { Text } from "ink"; import React, { useMemo } from "react"; import { logError } from "@utils/log"; function HighlightedCode({ code, language }) { const highlightedCode = useMemo(() => { try { if (supportsLanguage(language)) { return highlight(code, { language }); } else { logError( `Language not supported while highlighting code, falling back to markdown: ${language}` ); return highlight(code, { language: "markdown" }); } } catch (e) { if (e instanceof Error && e.message.includes("Unknown language")) { logError( `Language not supported while highlighting code, falling back to markdown: ${e}` ); return highlight(code, { language: "markdown" }); } } }, [code, language]); return /* @__PURE__ */ React.createElement(Text, null, highlightedCode); } export { HighlightedCode }; //# sourceMappingURL=HighlightedCode.js.map