fix: collapse markup whitespace so blockquotes render without blank lines

This commit is contained in:
randogoth 2026-10-11 10:43:12 +03:00
parent 204aee899a
commit 4e07c9a305
2 changed files with 112 additions and 36 deletions

View file

@ -165,6 +165,47 @@ void main() {
expect(text, contains('Visible & intact.'));
});
test('pretty-printed markup leaves no phantom blank content', () {
final source = '''
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>Indent</title><meta name="mews-profile" content="0.1" /></head>
<body>
<blockquote>
<p>No blank line above this.</p>
<p>And none between paragraphs.</p>
</blockquote>
<ul>
<li>
<a href="2026-10-08-post.html">2026-10-08 A dated link</a>
</li>
</ul>
<p>
A paragraph with
wrapped lines.
</p>
</body>
</html>
''';
final page = parseMewsPage(source: source, url: 'https://example.com/indent.html');
// The quote holds its two paragraphs and nothing else.
final quote = page.body[0] as QuoteBlock;
expect(quote.children, hasLength(2));
expect((quote.children.first as ParagraphBlock).inline.single,
isA<MewsText>());
// The list item starts directly with the link, no blank run before it.
final list = page.body[1] as ListBlock;
final item = (list.items.single.blocks.single as ParagraphBlock).inline;
final link = item.single as MewsLink;
expect((link.children.single as MewsText).text, '2026-10-08 A dated link');
// Interior line breaks collapse to single spaces, like in browsers.
final paragraph = (page.body[2] as ParagraphBlock).inline;
expect((paragraph.single as MewsText).text, 'A paragraph with wrapped lines.');
});
test('keeps bare inline content in list items and quotes', () {
final source = '''
<?xml version="1.0" encoding="UTF-8"?>