xuyuanwei678 221df3595d
fix(renderer): preserve literal text line breaks (#1132)
* fix(renderer): preserve literal text line breaks

* fix(renderer): preserve empty text paragraphs

* fix(renderer): scope line-break preservation to plain text

* fix(renderer): detect non-tag HTML markup

* style(renderer): format rich text tests
2026-08-17 21:45:46 +08:00

21 lines
686 B
TypeScript

import { describe, expect, it } from 'vitest';
import { preservesPlainTextLineBreaks } from '../../src/utils/richText';
describe('preservesPlainTextLineBreaks', () => {
it.each(['First line\nSecond line', 'A&nbsp;\nB', '2 < 3'])(
'keeps literal line endings for tag-free content: %j',
(content) => {
expect(preservesPlainTextLineBreaks(content)).toBe(true);
},
);
it.each([
'<p>A</p>\n<p>B</p>',
'<my-widget>content</my-widget>',
'A<!-- source note -->\nB',
'<!doctype html>\nA',
])('does not preserve source-formatting line endings in HTML markup: %j', (content) => {
expect(preservesPlainTextLineBreaks(content)).toBe(false);
});
});