-
Lets say I have the following markdown # Some heading
<div data-something="abc">
Something
<div>
<div data-something="xyz">
</div>
and i have to select that If I console the {
"type": "mdxJsxFlowElement",
"name": "div",
"attributes": [
{
"type": "mdxJsxAttribute",
"name": "data-something",
"value": "abc"
}
], I can select all thes import { match } from 'unist-util-select';
const isMatch = matches("mdxJsxFlowElement", node); but this will select all the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Don’t use select. It is likely slower than the better alternative. And the alternative makes your problem trivial to solve: https://github.com/syntax-tree/unist-util-select#when-should-i-use-this. import {visit} from 'unist-util-visit'
visit(tree, function (node) {
if (node.type === 'mdxJsxFlowElement' && /* put your extra conditions here */) {
}
}) |
Beta Was this translation helpful? Give feedback.
Don’t use select. It is likely slower than the better alternative. And the alternative makes your problem trivial to solve: https://github.com/syntax-tree/unist-util-select#when-should-i-use-this.