11# hast-util-select
22
3- [ ![ Build] [ build-badge ]] [ build ]
4- [ ![ Coverage] [ coverage-badge ]] [ coverage ]
5- [ ![ Downloads] [ downloads-badge ]] [ downloads ]
6- [ ![ Size] [ size-badge ]] [ size ]
7- [ ![ Sponsors] [ sponsors-badge ]] [ collective ]
8- [ ![ Backers] [ backers-badge ]] [ collective ]
9- [ ![ Chat] [ chat-badge ]] [ chat ]
3+ [ ![ Build] [ badge-build-image ]] [ badge-build-url ]
4+ [ ![ Coverage] [ badge-coverage-image ]] [ badge-coverage-url ]
5+ [ ![ Downloads] [ badge-downloads-image ]] [ badge-downloads-url ]
6+ [ ![ Size] [ badge-size-image ]] [ badge-size-url ]
107
11- [ hast] [ ] utility with equivalents for ` matches ` , ` querySelector ` ,
12- and ` querySelectorAll ` .
8+ [ hast] [ github-hast ] utility with equivalents for
9+ ` matches ` , ` querySelector ` , and ` querySelectorAll ` .
1310
1411## Contents
1512
@@ -46,17 +43,19 @@ This information is not stored in hast, so selectors like that don’t work.
4643This is a small utility that is quite useful, but is rather slow if you use it a
4744lot.
4845For each call, it has to walk the entire tree.
49- In some cases, walking the tree once with [ ` unist-util-visit ` ] [ unist-util-visit ]
46+ In some cases,
47+ walking the tree once with [ ` unist-util-visit ` ] [ github-unist-util-visit ]
5048is smarter, such as when you want to change certain nodes.
5149On the other hand, this is quite powerful and fast enough for many other cases.
5250
53- This utility is similar to [ ` unist-util-select ` ] [ unist-util-select ] , which can
54- find and match any unist node.
51+ This utility is similar to
52+ [ ` unist-util-select ` ] [ github-unist-util-select ] ,
53+ which can find and match any unist node.
5554
5655## Install
5756
58- This package is [ ESM only] [ esm ] .
59- In Node.js (version 16+), install with [ npm] [ ] :
57+ This package is [ ESM only] [ github-gist- esm] .
58+ In Node.js (version 16+), install with [ npm] [ npmjs-install ] :
6059
6160``` sh
6261npm install hast-util-select
@@ -120,7 +119,7 @@ This only checks that the given element matches the selector.
120119
121120* ` selector ` (` string ` )
122121 — CSS selector, such as (` h1 ` , ` a, b ` )
123- * ` node ` ([ ` Node ` ] [ node ] , optional)
122+ * ` node ` ([ ` Node ` ] [ github-hast-nodes ] , optional)
124123 — node that might match ` selector ` , should be an element
125124* ` space ` ([ ` Space ` ] [ api-space ] , default: ` 'html' ` )
126125 — name of namespace
@@ -147,13 +146,13 @@ matches('[lang|=en]', h('a', {lang: 'en-GB'})) // => true
147146### ` select(selector, tree[, space]) `
148147
149148Select the first element that matches ` selector ` in the given ` tree ` .
150- Searches the tree in * [ preorder] [ ] * .
149+ Searches the tree in * [ preorder] [ github-unist-preorder ] * .
151150
152151###### Parameters
153152
154153* ` selector ` (` string ` )
155154 — CSS selector, such as (` h1 ` , ` a, b ` )
156- * ` tree ` ([ ` Node ` ] [ node ] , optional)
155+ * ` tree ` ([ ` Node ` ] [ github-hast-nodes ] , optional)
157156 — tree to search
158157* ` space ` ([ ` Space ` ] [ api-space ] , default: ` 'html' ` )
159158 — name of namespace
@@ -196,13 +195,13 @@ Yields:
196195### ` selectAll(selector, tree[, space]) `
197196
198197Select all elements that match ` selector ` in the given ` tree ` .
199- Searches the tree in * [ preorder] [ ] * .
198+ Searches the tree in * [ preorder] [ github-unist-preorder ] * .
200199
201200###### Parameters
202201
203202* ` selector ` (` string ` )
204203 — CSS selector, such as (` h1 ` , ` a, b ` )
205- * ` tree ` ([ ` Node ` ] [ node ] , optional)
204+ * ` tree ` ([ ` Node ` ] [ github-hast-nodes ] , optional)
206205 — tree to search
207206* ` space ` ([ ` Space ` ] [ api-space ] , default: ` 'html' ` )
208207 — name of namespace
@@ -388,11 +387,11 @@ compatible with Node.js 16.
388387## Security
389388
390389This package does not change the syntax tree so there are no openings for
391- [cross-site scripting (XSS)][xss] attacks.
390+ [cross-site scripting (XSS)][wikipedia- xss] attacks.
392391
393392## Related
394393
395- * [ ` unist -util -select ` ](https:// github.com/syntax-tree/ unist-util-select)
394+ * [ ` unist -util -select ` ][ github- unist-util-select]
396395 — select unist nodes with CSS-like selectors
397396* [ ` hast -util -find -and -replace ` ](https://github.com/syntax-tree/hast-util-find-and-replace)
398397 — find and replace text in a hast tree
@@ -403,82 +402,74 @@ This package does not change the syntax tree so there are no openings for
403402
404403## Contribute
405404
406- See [ ` contributing .md ` ][contributing] in [ ` syntax -tree /.github ` ][health] for
407- ways to get started.
408- See [ ` support .md ` ][help] for ways to get help.
405+ See [ ` contributing .md ` ][health-contributing]
406+ in
407+ [ ` syntax -tree /.github ` ][health]
408+ for ways to get started.
409+ See [ ` support .md ` ][health-support] for ways to get help.
409410
410- This project has a [code of conduct][coc].
411+ This project has a [code of conduct][health- coc].
411412By interacting with this repository, organization, or community you agree to
412413abide by its terms.
413414
414415## License
415416
416- [MIT][license] © [Titus Wormer][author ]
417+ [MIT][file- license] © [Titus Wormer][wooorm ]
417418
418419<!-- Definitions -->
419420
420- [build-badge]: https://github.com/syntax-tree/hast-util-select/workflows/main/badge.svg
421-
422- [build]: https://github.com/syntax-tree/hast-util-select/actions
423-
424- [coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/hast-util-select.svg
425-
426- [coverage]: https://codecov.io/github/syntax-tree/hast-util-select
421+ [api-matches]: #matchesselector-node-space
427422
428- [downloads-badge ]: https://img.shields.io/npm/dm/hast-util-select.svg
423+ [api-select ]: #selectselector-tree-space
429424
430- [downloads ]: https://www.npmjs.com/package/hast-util-select
425+ [api-select-all ]: #selectallselector-tree-space
431426
432- [size-badge ]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=hast-util-select
427+ [api-space ]: #space
433428
434- [size ]: https://bundlejs .com/?q= hast-util-select
429+ [badge-build-image ]: https://github .com/syntax-tree/ hast-util-select/workflows/main/badge.svg
435430
436- [sponsors- badge]: https://opencollective .com/unified/sponsors/badge.svg
431+ [badge-build-url ]: https://github .com/syntax-tree/hast-util-select/actions
437432
438- [backers- badge]: https://opencollective.com/unified/backers/badge .svg
433+ [badge-coverage-image ]: https://img.shields.io/codecov/c/github/syntax-tree/hast-util-select .svg
439434
440- [collective ]: https://opencollective.com/unified
435+ [badge-coverage-url ]: https://codecov.io/github/syntax-tree/hast-util-select
441436
442- [chat- badge]: https://img.shields.io/badge/chat-discussions-success .svg
437+ [badge-downloads-image ]: https://img.shields.io/npm/dm/hast-util-select .svg
443438
444- [chat ]: https://github. com/syntax-tree/unist/discussions
439+ [badge-downloads-url ]: https://www.npmjs. com/package/hast-util-select
445440
446- [npm ]: https://docs.npmjs.com/cli/install
441+ [badge-size-image ]: https://img.shields.io/bundlejs/size/hast-util-select
447442
448- [esm ]: https://gist.github. com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
443+ [badge-size-url ]: https://bundlejs. com/?q=hast-util-select
449444
450445[esmsh]: https://esm.sh
451446
452- [typescript ]: https://www.typescriptlang.org
447+ [file-license ]: license
453448
454- [license ]: license
449+ [github-gist-esm ]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
455450
456- [author ]: https://wooorm .com
451+ [github-hast ]: https://github .com/syntax-tree/hast
457452
458- [health ]: https://github.com/syntax-tree/.github
453+ [github-hast-nodes ]: https://github.com/syntax-tree/hast#nodes
459454
460- [contributing ]: https://github.com/syntax-tree/.github/blob/main/contributing.md
455+ [github-unist-preorder ]: https://github.com/syntax-tree/unist#preorder
461456
462- [help ]: https://github.com/syntax-tree/.github/blob/main/support.md
457+ [github-unist-util-select ]: https://github.com/syntax-tree/unist-util-select
463458
464- [coc ]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
459+ [github-unist-util-visit ]: https://github.com/syntax-tree/unist-util-visit
465460
466- [preorder]: https://github.com/syntax-tree/unist#preorder
467-
468- [hast]: https://github.com/syntax-tree/hast
469-
470- [node]: https://github.com/syntax-tree/hast#nodes
461+ [health]: https://github.com/syntax-tree/.github
471462
472- [xss ]: https://en.wikipedia.org/wiki/Cross-site_scripting
463+ [health-coc ]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
473464
474- [unist-util-visit ]: https://github.com/syntax-tree/unist-util-visit
465+ [health-contributing ]: https://github.com/syntax-tree/.github/blob/main/contributing.md
475466
476- [unist-util-select ]: https://github.com/syntax-tree/unist-util-select
467+ [health-support ]: https://github.com/syntax-tree/.github/blob/main/support.md
477468
478- [api-matches ]: #matchesselector-node-space
469+ [npmjs-install ]: https://docs.npmjs.com/cli/install
479470
480- [api-select ]: #selectselector-tree-space
471+ [typescript ]: https://www.typescriptlang.org
481472
482- [api-select-all ]: #selectallselector-tree-space
473+ [wikipedia-xss ]: https://en.wikipedia.org/wiki/Cross-site_scripting
483474
484- [api-space ]: #space
475+ [wooorm ]: https://wooorm.com
0 commit comments