diff --git a/packages/core/src/utils/node.ts b/packages/core/src/utils/node.ts index 642607d200..469e5a69cb 100644 --- a/packages/core/src/utils/node.ts +++ b/packages/core/src/utils/node.ts @@ -1,12 +1,22 @@ -import cheerio from 'cheerio'; import { DomElement } from 'htmlparser2'; +/* + * A TextElement is a simple node that does not need complex processing. + */ export type TextElement = DomElement; +/* + * MbNode (MarkbindNode) is an element that can be operated on by cheerio and our own node processing + * methods. It must have a name (used to identify what kind of node it is), attributes (possibly empty), + * and children nodes (possibly empty). This type allows us to assert that these attributes exist. + */ export type MbNode = DomElement & cheerio.Element & { name: string, attribs: { [key: string]: any }, children: NodeOrText[], }; +/* + * NodeOrText is used before a node can be casted to either TextElement or MbNode. + */ export type NodeOrText = TextElement | MbNode;