Fix code leading spaces removal

This commit is contained in:
Enrico Ros
2024-07-14 14:37:29 -07:00
parent d969f55730
commit 98ff38f8e1
+2 -1
View File
@@ -99,7 +99,8 @@ function parseBlocksFromText(text: string, disableParsing: boolean, forceTextDif
switch (matchType) {
case 'codeBlock':
const blockTitle: string = (match[1] || '').trim();
const blockCode: string = match[2].trim();
// note: we don't trim blockCode to preserve leading spaces, however if the last line is only made of spaces, we trim that
const blockCode: string = match[2].replace(/\s+$/, '');
const blockEnd: string = match[3];
blocks.push({ type: 'codeb', blockTitle, blockCode, complete: blockEnd.startsWith('```') });
break;