File tree Expand file tree Collapse file tree 1 file changed +1
-12
lines changed
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/note-block Expand file tree Collapse file tree 1 file changed +1
-12
lines changed Original file line number Diff line number Diff line change @@ -300,29 +300,18 @@ function getEmbedInfo(url: string): EmbedInfo | null {
300300}
301301
302302/**
303- * Converts single newlines to markdown hard breaks (two trailing spaces + newline).
304- * This ensures that pressing Enter in the editor creates a visible line break in the preview.
305- * Preserves double newlines (paragraph breaks) and code block formatting.
303+ * Convert single newlines to markdown hard breaks, preserving code blocks
306304 */
307305function convertNewlinesToBreaks ( text : string ) : string {
308- // Split by code blocks to preserve their formatting
309306 const parts = text . split ( / ( ` ` ` [ \s \S ] * ?` ` ` | ` [ ^ ` \n ] + ` ) / g)
310307
311308 return parts
312309 . map ( ( part , index ) => {
313- // Odd indices are code blocks - don't modify them
314310 if ( index % 2 === 1 ) return part
315311
316- // For regular text, convert single newlines to hard breaks
317- // First, temporarily replace double newlines with a placeholder
318312 const placeholder = '\u0000DOUBLE_NEWLINE\u0000'
319313 let processed = part . replace ( / \n \n / g, placeholder )
320-
321- // Add two spaces before single newlines (markdown hard break syntax)
322- // But only if there aren't already two spaces before the newline
323314 processed = processed . replace ( / ( [ ^ \s \n ] ) ( \n ) (? ! \n ) / g, '$1 $2' )
324-
325- // Restore double newlines
326315 processed = processed . replace ( new RegExp ( placeholder , 'g' ) , '\n\n' )
327316
328317 return processed
You can’t perform that action at this time.
0 commit comments