Skip to content

Commit af2494f

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

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodejs 22.17.1

src/generators/llms-txt/utils/buildApiDocLink.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export const getEntryDescription = entry => {
1818
child => child.type === 'paragraph'
1919
);
2020

21+
console.log(descriptionNode);
22+
2123
if (!descriptionNode) {
2224
return '';
2325
}

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)