Skip to content

Commit d591b56

Browse files
committed
Improve
1 parent f7c4095 commit d591b56

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

packages/bundle/src/markdown/createStreamingRenderer.spec.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,14 @@ describe('createStreamingRenderer', () => {
112112
expect(split![1]).toBe('<p>Second paragraph</p>');
113113
});
114114

115-
test('should preserve both paragraphs in textContent', () => {
115+
test('should preserve newline between paragraphs in textContent', () => {
116116
const { container, nextOptions, renderer } = setup();
117117

118118
renderer.next('First\n\nSecond', nextOptions());
119119

120120
expect(container.textContent).toContain('First');
121121
expect(container.textContent).toContain('Second');
122+
expect(container.textContent).toMatch(/First\s+Second/u);
122123
});
123124

124125
test('should split three paragraphs with two committed and one active', () => {
@@ -133,6 +134,15 @@ describe('createStreamingRenderer', () => {
133134
expect(split![0]).toContain('Block B');
134135
expect(split![1]).toBe('<p>Block C</p>');
135136
});
137+
138+
test('should preserve newline in textContent for code span followed by paragraph', () => {
139+
const { container, nextOptions, renderer } = setup();
140+
141+
renderer.next('`t=undefined`\n\nA quick', nextOptions());
142+
143+
// The \n between the two <p> blocks must survive the committed/active split.
144+
expect(container.textContent).toMatch(/t=undefined\nA quick/u);
145+
});
136146
});
137147

138148
describe('htmlFlow blocks', () => {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export default function serializeDocumentFragmentIntoString(documentFragment: DocumentFragment): string {
2-
return new XMLSerializer().serializeToString(documentFragment).trim();
2+
return new XMLSerializer().serializeToString(documentFragment);
33
}

0 commit comments

Comments
 (0)