mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-20 18:14:29 -07:00
feat: Add markdown toggle (alt+m) to switch between rendered and raw… (#10383)
Co-authored-by: Jacob Richman <jacob314@gmail.com>
This commit is contained in:
@@ -17,6 +17,7 @@ interface MarkdownDisplayProps {
|
||||
isPending: boolean;
|
||||
availableTerminalHeight?: number;
|
||||
terminalWidth: number;
|
||||
renderMarkdown?: boolean;
|
||||
}
|
||||
|
||||
// Constants for Markdown parsing and rendering
|
||||
@@ -31,9 +32,31 @@ const MarkdownDisplayInternal: React.FC<MarkdownDisplayProps> = ({
|
||||
isPending,
|
||||
availableTerminalHeight,
|
||||
terminalWidth,
|
||||
renderMarkdown = true,
|
||||
}) => {
|
||||
const settings = useSettings();
|
||||
|
||||
if (!text) return <></>;
|
||||
|
||||
// Raw markdown mode - display syntax-highlighted markdown without rendering
|
||||
if (!renderMarkdown) {
|
||||
// Hide line numbers in raw markdown mode as they are confusing due to chunked output
|
||||
const colorizedMarkdown = colorizeCode(
|
||||
text,
|
||||
'markdown',
|
||||
availableTerminalHeight,
|
||||
terminalWidth - CODE_BLOCK_PREFIX_PADDING,
|
||||
undefined,
|
||||
settings,
|
||||
true, // hideLineNumbers
|
||||
);
|
||||
return (
|
||||
<Box paddingLeft={CODE_BLOCK_PREFIX_PADDING} flexDirection="column">
|
||||
{colorizedMarkdown}
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
const lines = text.split(/\r?\n/);
|
||||
const headerRegex = /^ *(#{1,4}) +(.*)/;
|
||||
const codeFenceRegex = /^ *(`{3,}|~{3,}) *(\w*?) *$/;
|
||||
|
||||
Reference in New Issue
Block a user