Skip to content

Commit f312947

Browse files
committed
added remark-breaks to allow single new line
1 parent 30dcd98 commit f312947

File tree

3 files changed

+9
-24
lines changed

3 files changed

+9
-24
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/note-block/note-block.tsx

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { memo, useCallback, useMemo } from 'react'
22
import ReactMarkdown from 'react-markdown'
33
import type { NodeProps } from 'reactflow'
4+
import remarkBreaks from 'remark-breaks'
45
import remarkGfm from 'remark-gfm'
56
import { cn } from '@/lib/core/utils/cn'
67
import { BLOCK_DIMENSIONS } from '@/lib/workflows/blocks/block-dimensions'
@@ -299,35 +300,13 @@ function getEmbedInfo(url: string): EmbedInfo | null {
299300
return null
300301
}
301302

302-
/**
303-
* Convert single newlines to markdown hard breaks, preserving code blocks
304-
*/
305-
function convertNewlinesToBreaks(text: string): string {
306-
const parts = text.split(/(```[\s\S]*?```|`[^`\n]+`)/g)
307-
308-
return parts
309-
.map((part, index) => {
310-
if (index % 2 === 1) return part
311-
312-
const placeholder = '\u0000DOUBLE_NEWLINE\u0000'
313-
let processed = part.replace(/\n\n/g, placeholder)
314-
processed = processed.replace(/([^\s\n])(\n)(?!\n)/g, '$1 $2')
315-
processed = processed.replace(new RegExp(placeholder, 'g'), '\n\n')
316-
317-
return processed
318-
})
319-
.join('')
320-
}
321-
322303
/**
323304
* Compact markdown renderer for note blocks with tight spacing
324305
*/
325306
const NoteMarkdown = memo(function NoteMarkdown({ content }: { content: string }) {
326-
const processedContent = convertNewlinesToBreaks(content)
327-
328307
return (
329308
<ReactMarkdown
330-
remarkPlugins={[remarkGfm]}
309+
remarkPlugins={[remarkGfm, remarkBreaks]}
331310
components={{
332311
p: ({ children }: any) => (
333312
<p className='mb-1 break-words text-[var(--text-primary)] text-sm leading-[1.25rem] last:mb-0'>
@@ -490,7 +469,7 @@ const NoteMarkdown = memo(function NoteMarkdown({ content }: { content: string }
490469
),
491470
}}
492471
>
493-
{processedContent}
472+
{content}
494473
</ReactMarkdown>
495474
)
496475
})

apps/sim/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@
148148
"redis": "5.10.0",
149149
"rehype-autolink-headings": "^7.1.0",
150150
"rehype-slug": "^6.0.0",
151+
"remark-breaks": "^4.0.0",
151152
"remark-gfm": "4.0.1",
152153
"resend": "^4.1.2",
153154
"rss-parser": "3.13.0",

bun.lock

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)