-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
11 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |