Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jovyntls committed Mar 16, 2023
1 parent dd78e39 commit dbf43e8
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/core/src/utils/node.ts
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit dbf43e8

Please sign in to comment.