Skip to content

Commit 22ba75e

Browse files
committed
fix(html): ensure lines in block code are wrapped
1 parent 8904fd5 commit 22ba75e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/utils/html/html_muncher.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,9 @@ final class _Muncher with LoggerMixin {
582582
}
583583

584584
List<InlineSpan>? _buildBlockCode(uh.Element element) {
585-
final text = element.querySelector('div')?.innerText.trim() ?? '';
585+
// Usually each line in the block code is ended with `<br>` tag, but rarely it does not.
586+
// To ensure each line is wrapped correctly, extract each line (contents in each `<div>`) and manually place them.
587+
final text = element.querySelectorAll('div ol li').map((e) => e.innerText.trim()).join('\n');
586588
state
587589
..headingBrNodePassed = true
588590
..elevation += _elevationStep;

0 commit comments

Comments
 (0)