@@ -84,6 +84,21 @@ class UnimplementedBlockContentNode extends BlockContentNode
84
84
// No ==/hashCode, because htmlNode is a whole subtree.
85
85
}
86
86
87
+ /// A block content node whose children are inline content nodes.
88
+ ///
89
+ /// A node of this type expects a block layout context from its parent,
90
+ /// but provides an inline layout context for its children.
91
+ ///
92
+ /// See also [InlineContainerNode] .
93
+ class BlockInlineContainerNode extends BlockContentNode {
94
+ const BlockInlineContainerNode ({
95
+ super .debugHtmlNode,
96
+ required this .nodes,
97
+ });
98
+
99
+ final List <InlineContentNode > nodes;
100
+ }
101
+
87
102
// A `br` element.
88
103
class LineBreakNode extends BlockContentNode {
89
104
const LineBreakNode ({super .debugHtmlNode});
@@ -105,15 +120,13 @@ class LineBreakNode extends BlockContentNode {
105
120
// with [wasImplicit].
106
121
//
107
122
// See also [parseImplicitParagraphBlockContentList].
108
- class ParagraphNode extends BlockContentNode {
123
+ class ParagraphNode extends BlockInlineContainerNode {
109
124
const ParagraphNode (
110
- {super .debugHtmlNode, this .wasImplicit = false , required this .nodes });
125
+ {super .debugHtmlNode, required super .nodes, this .wasImplicit = false });
111
126
112
127
/// True when there was no corresponding `p` element in the original HTML.
113
128
final bool wasImplicit;
114
129
115
- final List <InlineContentNode > nodes;
116
-
117
130
@override
118
131
String toString () => '${objectRuntimeType (this , 'ParagraphNode' )}(wasImplicit: $wasImplicit , $nodes )' ;
119
132
}
@@ -129,11 +142,14 @@ class ListNode extends BlockContentNode {
129
142
130
143
enum HeadingLevel { h1, h2, h3, h4, h5, h6 }
131
144
132
- class HeadingNode extends BlockContentNode {
133
- const HeadingNode (this .level, this .nodes, {super .debugHtmlNode});
145
+ class HeadingNode extends BlockInlineContainerNode {
146
+ const HeadingNode ({
147
+ super .debugHtmlNode,
148
+ required super .nodes,
149
+ required this .level,
150
+ });
134
151
135
152
final HeadingLevel level;
136
- final List <InlineContentNode > nodes;
137
153
}
138
154
139
155
class QuotationNode extends BlockContentNode {
@@ -243,6 +259,8 @@ class LineBreakInlineNode extends InlineContentNode {
243
259
/// the [InlineSpan] s built from this node's children. In that case,
244
260
/// the children participate in the same paragraph layout as this node
245
261
/// itself does.
262
+ ///
263
+ /// See also [BlockInlineContainerNode] .
246
264
abstract class InlineContainerNode extends InlineContentNode {
247
265
const InlineContainerNode ({super .debugHtmlNode, required this .nodes});
248
266
@@ -538,7 +556,7 @@ BlockContentNode parseBlockContent(dom.Node node) {
538
556
if (headingLevel == HeadingLevel .h6 && classes.isEmpty) {
539
557
// TODO(#192) handle h1, h2, h3, h4, h5
540
558
return HeadingNode (
541
- headingLevel! , inlineNodes (), debugHtmlNode: debugHtmlNode);
559
+ level : headingLevel! , nodes : inlineNodes (), debugHtmlNode: debugHtmlNode);
542
560
}
543
561
544
562
if (localName == 'blockquote' && classes.isEmpty) {
0 commit comments