mdast-util-hidden
mdast-util-hidden
createHiddenNode
▸ createHiddenNode(children
): Hidden
Returns a new Hidden
node ready to be inserted into a mdast tree.
Name | Type |
---|---|
children |
RootContent [] |
packages/mdast-util-hidden/src/index.ts:30
▸ hide<Nodes
>(«destructured»
): void
Inserts a Hidden
node as a child of parent
at index
. Any nodes
passed
in will become the hidden children of this new node.
Name | Type |
---|---|
Nodes |
extends RootContent [] |
Name | Type | Description |
---|---|---|
«destructured» |
Object |
- |
› index |
number |
- |
› nodes |
Nodes |
- |
› parent |
Parent |
- |
› replaceChildAtIndex? |
boolean |
If replaceChildAtIndex is true , the child node of parent at index will be replaced by the new Hidden node. On the other hand, if replaceChildAtIndex is false , this function will not remove any nodes from parent . In this case, if you do not manually remove the node at index , you must skip two nodes ahead instead of just one when using a visitor or risk an infinite loop! Default ts true Example typescript visit(tree, 'heading', (node, index, parent) => { if (index !== undefined && parent !== undefined) { hide({ nodes: [node], index, parent, replaceChildAtIndex: false }); return [SKIP, index + 2]; // <- +2 here is IMPORTANT } }); |
void
packages/mdast-util-hidden/src/index.ts:49
isHidden
▸ isHidden(node
): node is Hidden
Type guard that returns true if node
is a well-formed Hidden
node
instance.
Name | Type |
---|---|
node |
Node |
node is Hidden
packages/mdast-util-hidden/src/index.ts:41
▸ reveal<Nodes
>(«destructured»
): void
Replaces the child node of parent
at index
with the hidden children of
one or more Hidden
nodes
.
Name | Type |
---|---|
Nodes |
extends Hidden [] |
Name | Type |
---|---|
«destructured» |
Object |
› index |
number |
› nodes |
Nodes |
› parent |
Parent |
void
packages/mdast-util-hidden/src/index.ts:92
▸ visitAndReveal<Tree
>(«destructured»
): void
Walks tree
using unist-util-visit to search for any Hidden
nodes. Upon
encountering a Hidden
node, visitor
is called if provided.
If visitor
is provided but returns false
, reveal
is not called and the
hidden is not revealed. Otherwise, reveal
will always be called.
If visitor
is provided and returns a defined value other than false
, that
value will be passed through to unist-util-visit. If visitor
is not
provided, or it returns undefined
, [SKIP, index]
will be passed through
instead.
Name | Type |
---|---|
Tree |
extends Node |
Name | Type | Description |
---|---|---|
«destructured» |
Object |
- |
› reverse? |
boolean |
See https://github.com/syntax-tree/unist-util-visit#visittree-test-visitor-reverse Default ts false |
› tree |
Tree |
See https://github.com/syntax-tree/unist-util-visit#visittree-test-visitor-reverse |
› visitor? |
Visitor |
If visitor is provided but returns false , reveal is not called and the hidden is not revealed. Otherwise, reveal will always be called. If visitor is provided and returns a defined value other than false , that value will be passed through to unist-util-visit. If visitor is not provided, or it returns undefined , [SKIP, index] will be passed through instead. |
void