mdast utility to remove empty links from a tree.
Links are considered empty if they do not contain non-whitespace characters.
npm:
npm install mdast-squeeze-links
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:
{
type: 'root',
children: [ { type: 'link', url: '#about', children: [{ type: 'text', value: 'About' }] } ]
}
Modifies tree in-place.
Returns tree
.
remark-squeeze-links
— remark plugin wrapper
See contributing.md
in syntax-tree/.github
for ways to get
started.
See support.md
for ways to get help.
This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.