@@ -17,7 +17,7 @@ CustomRenderMatcher tagMatcher(String tag) => (context) {
17
17
18
18
CustomRenderMatcher blockElementMatcher () => (context) {
19
19
return (context.tree.style.display == Display .BLOCK ||
20
- context.tree.style.display == Display .INLINE_BLOCK ) &&
20
+ context.tree.style.display == Display .INLINE_BLOCK ) &&
21
21
(context.tree.children.isNotEmpty ||
22
22
context.tree.element? .localName == "hr" );
23
23
};
@@ -132,108 +132,105 @@ CustomRender blockElementRender({Style? style, List<InlineSpan>? children}) =>
132
132
alignment: PlaceholderAlignment .baseline,
133
133
baseline: TextBaseline .alphabetic,
134
134
child: CSSBoxWidget .withInlineSpanChildren (
135
- key: context.key,
136
- style: style ?? context.tree.style,
137
- shrinkWrap: context.parser.shrinkWrap,
138
- childIsReplaced: REPLACED_EXTERNAL_ELEMENTS .contains (context.tree.name),
139
- children: children ??
140
- context.tree.children
141
- .expandIndexed ((i, childTree) => [
142
- context.parser.parseTree (context, childTree),
143
- //TODO can this newline be added in a different step?
144
- if (i != context.tree.children.length - 1 &&
145
- childTree.style.display == Display .BLOCK &&
146
- childTree.element? .localName != "html" &&
147
- childTree.element? .localName != "body" )
148
- TextSpan (text: "\n " ),
149
- ]).toList (),
135
+ key: context.key,
136
+ style: style ?? context.tree.style,
137
+ shrinkWrap: context.parser.shrinkWrap,
138
+ childIsReplaced:
139
+ REPLACED_EXTERNAL_ELEMENTS .contains (context.tree.name),
140
+ children: children ??
141
+ context.tree.children
142
+ .expandIndexed ((i, childTree) => [
143
+ context.parser.parseTree (context, childTree),
144
+ //TODO can this newline be added in a different step?
145
+ if (i != context.tree.children.length - 1 &&
146
+ childTree.style.display == Display .BLOCK &&
147
+ childTree.element? .localName != "html" &&
148
+ childTree.element? .localName != "body" )
149
+ TextSpan (text: "\n " ),
150
+ ])
151
+ .toList (),
150
152
),
151
153
);
152
154
});
153
155
154
156
CustomRender listElementRender (
155
157
{Style ? style, Widget ? child, List <InlineSpan >? children}) =>
156
158
CustomRender .inlineSpan (
157
- inlineSpan: (context, buildChildren) => WidgetSpan (
158
- child: CSSBoxWidget (
159
- key: context.key,
160
- style: style ?? context.tree.style,
161
- shrinkWrap: context.parser.shrinkWrap,
162
- child: Row (
163
- crossAxisAlignment: CrossAxisAlignment .start,
164
- mainAxisSize: MainAxisSize .min,
165
- textDirection:
166
- style? .direction ?? context.tree.style.direction,
167
- children: [
168
- (style? .listStylePosition ??
169
- context.tree.style.listStylePosition) ==
170
- ListStylePosition .OUTSIDE
171
- ? Padding (
172
- padding: style? .padding? .nonNegative ??
173
- context.tree.style.padding? .nonNegative ??
174
- EdgeInsets .only (
175
- left: (style? .direction ??
176
- context.tree.style.direction) !=
177
- TextDirection .rtl
178
- ? 10.0
179
- : 0.0 ,
180
- right: (style? .direction ??
181
- context.tree.style.direction) ==
182
- TextDirection .rtl
183
- ? 10.0
184
- : 0.0 ),
185
- child: style? .markerContent ??
186
- context.style.markerContent)
187
- : Container (height: 0 , width: 0 ),
188
- Text ("\u 0020" ,
189
- textAlign: TextAlign .right,
190
- style: TextStyle (fontWeight: FontWeight .w400)),
191
- Expanded (
192
- child: Padding (
193
- padding: (style? .listStylePosition ??
194
- context.tree.style.listStylePosition) ==
195
- ListStylePosition .INSIDE
196
- ? EdgeInsets .only (
197
- left: (style? .direction ??
198
- context.tree.style.direction) !=
199
- TextDirection .rtl
200
- ? 10.0
201
- : 0.0 ,
202
- right: (style? .direction ??
203
- context.tree.style.direction) ==
204
- TextDirection .rtl
205
- ? 10.0
206
- : 0.0 )
207
- : EdgeInsets .zero,
208
- child: CSSBoxWidget .withInlineSpanChildren (
209
- children: _getListElementChildren (
210
- style? .listStylePosition ??
211
- context.tree.style.listStylePosition,
212
- buildChildren)
213
- ..insertAll (
214
- 0 ,
215
- context.tree.style.listStylePosition ==
216
- ListStylePosition .INSIDE
217
- ? [
218
- WidgetSpan (
219
- alignment:
220
- PlaceholderAlignment
221
- .middle,
222
- child: style? .markerContent ??
223
- context.style
224
- .markerContent ??
225
- Container (
226
- height: 0 , width: 0 ))
227
- ]
228
- : []),
229
- style: style ?? context.style,
230
- ),
231
- ),
232
- ),
233
- ],
159
+ inlineSpan: (context, buildChildren) => WidgetSpan (
160
+ child: CSSBoxWidget (
161
+ key: context.key,
162
+ style: style ?? context.tree.style,
163
+ shrinkWrap: context.parser.shrinkWrap,
164
+ child: Row (
165
+ crossAxisAlignment: CrossAxisAlignment .start,
166
+ mainAxisSize: MainAxisSize .min,
167
+ textDirection: style? .direction ?? context.tree.style.direction,
168
+ children: [
169
+ (style? .listStylePosition ??
170
+ context.tree.style.listStylePosition) ==
171
+ ListStylePosition .OUTSIDE
172
+ ? Padding (
173
+ padding: style? .padding? .nonNegative ??
174
+ context.tree.style.padding? .nonNegative ??
175
+ EdgeInsets .only (
176
+ left: (style? .direction ??
177
+ context.tree.style.direction) !=
178
+ TextDirection .rtl
179
+ ? 10.0
180
+ : 0.0 ,
181
+ right: (style? .direction ??
182
+ context.tree.style.direction) ==
183
+ TextDirection .rtl
184
+ ? 10.0
185
+ : 0.0 ),
186
+ child:
187
+ style? .markerContent ?? context.style.markerContent)
188
+ : Container (height: 0 , width: 0 ),
189
+ Text ("\u 0020" ,
190
+ textAlign: TextAlign .right,
191
+ style: TextStyle (fontWeight: FontWeight .w400)),
192
+ Expanded (
193
+ child: Padding (
194
+ padding: (style? .listStylePosition ??
195
+ context.tree.style.listStylePosition) ==
196
+ ListStylePosition .INSIDE
197
+ ? EdgeInsets .only (
198
+ left: (style? .direction ??
199
+ context.tree.style.direction) !=
200
+ TextDirection .rtl
201
+ ? 10.0
202
+ : 0.0 ,
203
+ right: (style? .direction ??
204
+ context.tree.style.direction) ==
205
+ TextDirection .rtl
206
+ ? 10.0
207
+ : 0.0 )
208
+ : EdgeInsets .zero,
209
+ child: CSSBoxWidget .withInlineSpanChildren (
210
+ children: _getListElementChildren (
211
+ style? .listStylePosition ??
212
+ context.tree.style.listStylePosition,
213
+ buildChildren)
214
+ ..insertAll (
215
+ 0 ,
216
+ context.tree.style.listStylePosition ==
217
+ ListStylePosition .INSIDE
218
+ ? [
219
+ WidgetSpan (
220
+ alignment: PlaceholderAlignment .middle,
221
+ child: style? .markerContent ??
222
+ context.style.markerContent ??
223
+ Container (height: 0 , width: 0 ))
224
+ ]
225
+ : []),
226
+ style: style ?? context.style,
227
+ ),
234
228
),
235
229
),
236
- ),
230
+ ],
231
+ ),
232
+ ),
233
+ ),
237
234
);
238
235
239
236
CustomRender replacedElementRender (
0 commit comments