Skip to content

Commit a03c898

Browse files
committed
katex [nfc]: Add docs explaining the different content-node classes
1 parent af80c52 commit a03c898

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

lib/model/content.dart

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,11 @@ class CodeBlockSpanNode extends ContentNode {
341341
}
342342
}
343343

344+
/// A complete KaTeX math expression within Zulip content,
345+
/// whether block or inline.
346+
///
347+
/// The content nodes that are descendants of this node
348+
/// will all be of KaTeX-specific types, such as [KatexNode].
344349
sealed class MathNode extends ContentNode {
345350
const MathNode({
346351
super.debugHtmlNode,
@@ -374,10 +379,15 @@ sealed class MathNode extends ContentNode {
374379
}
375380
}
376381

382+
/// A content node that expects a generic KaTeX context from its parent.
383+
///
384+
/// Each of these will have a [MathNode] as an ancestor.
377385
sealed class KatexNode extends ContentNode {
378386
const KatexNode({super.debugHtmlNode});
379387
}
380388

389+
/// A generic KaTeX content node, corresponding to any span in KaTeX HTML
390+
/// that we don't otherwise specially handle.
381391
class KatexSpanNode extends KatexNode {
382392
const KatexSpanNode({
383393
this.styles = const KatexSpanStyles(),
@@ -411,6 +421,7 @@ class KatexSpanNode extends KatexNode {
411421
}
412422
}
413423

424+
/// A KaTeX strut, corresponding to a `span.strut` node in KaTeX HTML.
414425
class KatexStrutNode extends KatexNode {
415426
const KatexStrutNode({
416427
required this.heightEm,
@@ -429,6 +440,12 @@ class KatexStrutNode extends KatexNode {
429440
}
430441
}
431442

443+
/// A KaTeX "vertical list", corresponding to a `span.vlist-t` in KaTeX HTML.
444+
///
445+
/// These nodes in KaTeX HTML have a very specific structure.
446+
/// The children of these nodes in our tree correspond in the HTML to
447+
/// certain great-grandchildren (certain `> .vlist-r > .vlist > span`)
448+
/// of the `.vlist-t` node.
432449
class KatexVlistNode extends KatexNode {
433450
const KatexVlistNode({
434451
required this.rows,
@@ -443,6 +460,11 @@ class KatexVlistNode extends KatexNode {
443460
}
444461
}
445462

463+
/// An element of a KaTeX "vertical list"; a child of a [KatexVlistNode].
464+
///
465+
/// These correspond to certain `.vlist-t > .vlist-r > .vlist > span` nodes
466+
/// in KaTeX HTML. The [KatexVlistNode] parent in our tree
467+
/// corresponds to the `.vlist-t` great-grandparent in the HTML.
446468
class KatexVlistRowNode extends ContentNode {
447469
const KatexVlistRowNode({
448470
required this.verticalOffsetEm,
@@ -465,6 +487,11 @@ class KatexVlistRowNode extends ContentNode {
465487
}
466488
}
467489

490+
/// A KaTeX node corresponding to negative values for `margin-left`
491+
/// or `margin-right` in the inline CSS style of a KaTeX HTML node.
492+
///
493+
/// The parser synthesizes these as additional nodes, not corresponding
494+
/// directly to any node in the HTML.
468495
class KatexNegativeMarginNode extends KatexNode {
469496
const KatexNegativeMarginNode({
470497
required this.leftOffsetEm,

0 commit comments

Comments
 (0)