Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/inkdropapp/mdast-squeeze-links
mdast utility to remove empty links from a tree
https://github.com/inkdropapp/mdast-squeeze-links
markdown mdasst micromark unist
Last synced: about 1 month ago
JSON representation
mdast utility to remove empty links from a tree
- Host: GitHub
- URL: https://github.com/inkdropapp/mdast-squeeze-links
- Owner: inkdropapp
- License: mit
- Created: 2021-04-01T03:00:49.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-27T00:08:52.000Z (almost 2 years ago)
- Last Synced: 2024-10-24T02:29:50.616Z (3 months ago)
- Topics: markdown, mdasst, micromark, unist
- Language: JavaScript
- Homepage:
- Size: 636 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mdast-squeeze-links
[**mdast**][mdast] utility to remove empty links from a tree.
Links are considered empty if they do not contain non-whitespace
characters.## Install
[npm][]:
```sh
npm install mdast-squeeze-links
```## Use
```js
import { u } from 'unist-builder'
import { squeezeLinks } from 'mdast-squeeze-links'const tree = u('root', [
u('link', { url: '#about' }, [u('text', 'About')]),
u('link', { url: '#about' }, [u('text', ' ')])
])squeezeLinks(tree)
console.dir(tree, { depth: null })
```Yields:
```js
{
type: 'root',
children: [ { type: 'link', url: '#about', children: [{ type: 'text', value: 'About' }] } ]
}
```## API
### `squeezeLinks(tree)`
Modifies [tree][] in-place.
Returns `tree`.## Related
- [`remark-squeeze-links`][remark-squeeze-links]
— [**remark**][remark] plugin wrapper## Contribute
See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get
started.
See [`support.md`][support] for ways to get help.This project has a [code of conduct][coc].
By interacting with this repository, organization, or community you agree to
abide by its terms.## License
[MIT][license] © [Takuya Matsuyama][author]
[npm]: https://docs.npmjs.com/cli/install
[contributing]: https://github.com/syntax-tree/.github/blob/HEAD/contributing.md
[support]: https://github.com/syntax-tree/.github/blob/HEAD/support.md
[coc]: https://github.com/syntax-tree/.github/blob/HEAD/code-of-conduct.md
[tree]: https://github.com/syntax-tree/unist#tree
[mdast]: https://github.com/syntax-tree/mdast
[remark]: https://github.com/remarkjs/remark
[remark-squeeze-links]: https://github.com/remarkjs/remark-squeeze-links
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
[hast]: https://github.com/syntax-tree/hast
[license]: LICENSE
[author]: https://www.craftz.dog/