Skip to content

Commit 4b9ee2d

Browse files
committed
fix: trim trailing whitespace while preserving two-space line breaks
1 parent a181639 commit 4b9ee2d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/visitor.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,10 @@ export function getMarkdownForHtmlNodes(instance: NodeHtmlMarkdown, rootNode: Ht
316316
'$1'
317317
);
318318

319-
return trimNewLines(result);
319+
// Trim newlines and any trailing space (but preserve two-space line breaks)
320+
result = trimNewLines(result);
321+
if (result.endsWith(' ') && !result.endsWith(' ')) result = result.trimEnd();
322+
return result;
320323
}
321324

322325
// endregion

0 commit comments

Comments
 (0)