Skip to content

Commit 16ce3e1

Browse files
committed
katex [nfc]: Factor out MathNode from its block-vs-inline variants
1 parent 1ca7f8a commit 16ce3e1

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

lib/model/content.dart

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,8 @@ class CodeBlockSpanNode extends ContentNode {
341341
}
342342
}
343343

344-
class MathBlockNode extends BlockContentNode {
345-
const MathBlockNode({
344+
abstract class MathNode extends ContentNode {
345+
const MathNode({
346346
super.debugHtmlNode,
347347
required this.texSource,
348348
required this.nodes,
@@ -402,6 +402,14 @@ class KatexNode extends ContentNode {
402402
}
403403
}
404404

405+
class MathBlockNode extends MathNode implements BlockContentNode {
406+
const MathBlockNode({
407+
super.debugHtmlNode,
408+
required super.texSource,
409+
required super.nodes,
410+
});
411+
}
412+
405413
class ImageNodeList extends BlockContentNode {
406414
const ImageNodeList(this.images, {super.debugHtmlNode});
407415

@@ -863,26 +871,12 @@ class ImageEmojiNode extends EmojiNode {
863871
}
864872
}
865873

866-
class MathInlineNode extends InlineContentNode {
874+
class MathInlineNode extends MathNode implements InlineContentNode {
867875
const MathInlineNode({
868876
super.debugHtmlNode,
869-
required this.texSource,
870-
required this.nodes,
877+
required super.texSource,
878+
required super.nodes,
871879
});
872-
873-
final String texSource;
874-
final List<KatexNode>? nodes;
875-
876-
@override
877-
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
878-
super.debugFillProperties(properties);
879-
properties.add(StringProperty('texSource', texSource));
880-
}
881-
882-
@override
883-
List<DiagnosticsNode> debugDescribeChildren() {
884-
return nodes?.map((node) => node.toDiagnosticsNode()).toList() ?? const [];
885-
}
886880
}
887881

888882
class GlobalTimeNode extends InlineContentNode {

0 commit comments

Comments
 (0)