Skip to content

Commit fdb68e9

Browse files
committed
proper rendering of multiline code blocks for inline explanations
Signed-off-by: Akshat Batra <[email protected]>
1 parent 7ee6246 commit fdb68e9

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/ai-assistant/prompts.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ export const prepareSystemPrompt = {
4545

4646
let prompt = `You are a helpful assistant that explains Accord Project ${typeName} code clearly and concisely.
4747
Focus on what the code does, its purpose, and any important details about its structure or syntax.
48-
Provide easy to understand explanations for developers.\n\n`;
49-
48+
Provide easy to understand explanations for developers. You can break down the code in detail line-by-line
49+
but don't include the complete code block in your response as it is, user already knows their selection.\n\n`;
50+
5051
return includeEditorContents(prompt, aiConfig, editorsContent);
5152
},
5253

src/components/CodeSelectionMenu.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,20 @@ const CodeSelectionMenu: React.FC<CodeSelectionMenuProps> = ({
169169
<div className="text-sm text-gray-700 prose lg:prose-md">
170170
<ReactMarkdown
171171
components={{
172-
code: ({ children, className }) => <code className={`bg-gray-200 p-1 rounded-md before:content-[''] after:content-[''] ${className}`}>{children}</code>,
172+
pre: ({ children }) => {
173+
return (
174+
<pre className="[&_code]:bg-transparent">
175+
{children}
176+
</pre>
177+
);
178+
},
179+
code: ({ children, className }) => {
180+
return (
181+
<code className={`bg-gray-200 p-1 rounded-md before:content-[''] after:content-[''] ${className}`}>
182+
{children}
183+
</code>
184+
);
185+
}
173186
}}>
174187
{explanation}
175188
</ReactMarkdown>

0 commit comments

Comments
 (0)