Skip to content

Commit 229552c

Browse files
committed
fix: handle multi-line paragraphs
1 parent 56c44d9 commit 229552c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/utils/unist.mjs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,14 @@ export const transformNodeToString = node => {
1616
return `**${transformNodesToString(node.children)}**`;
1717
case 'emphasis':
1818
return `_${transformNodesToString(node.children)}_`;
19-
default:
20-
return node.children ? transformNodesToString(node.children) : node.value;
19+
default: {
20+
if (node.children) {
21+
return transformNodesToString(node.children);
22+
}
23+
24+
// Replace line breaks (\n) with spaces to keep text in a single line
25+
return node.value?.replace(/\n/g, ' ') || '';
26+
}
2127
}
2228
};
2329

0 commit comments

Comments
 (0)