-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
fc291b9
commit 69a5607
Showing
4 changed files
with
17 additions
and
37 deletions.
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
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
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,20 +1,18 @@ | ||
import { Plugin, Transformer } from 'unified'; | ||
import { Parent, NodeData, Node } from 'unist'; | ||
import { visit } from './visit'; | ||
import { Plugin } from 'unified'; | ||
import { Root, Element } from 'hast'; | ||
import { Node, Data } from 'unist'; | ||
import { visit } from 'unist-util-visit'; | ||
|
||
export * from './visit'; | ||
export type RehypeRewriteOptions = (node: Node<Data>, index: number | null, parent: Root | Element | null) => void; | ||
|
||
export type RehypeRewriteOptions = (node: NodeData<Parent>, index: number, parent: NodeData<Parent>) => void | ||
|
||
const remarkRewrite: Plugin<[RehypeRewriteOptions?]> = (handle): Transformer => { | ||
return transformer; | ||
function transformer(tree: Node<NodeData<Parent>>): void { | ||
visit(tree as any, (node: NodeData<Parent>, index: number, parent: NodeData<Parent>) => { | ||
const remarkRewrite: Plugin<[RehypeRewriteOptions?], Root> = (handle) => { | ||
return (tree) => { | ||
visit(tree, (node, index, parent) => { | ||
if (handle && typeof handle === 'function') { | ||
handle(node, index, parent) | ||
handle(node, index, parent); | ||
} | ||
}) | ||
}); | ||
} | ||
} | ||
|
||
export default remarkRewrite | ||
export default remarkRewrite; |
This file was deleted.
Oops, something went wrong.