hast-util-insert
v1.0.0
Published
A [hast][] utility to insert [nodes][] into a tree, at a location in the tree that is specified by a selector string.
Downloads
1,857
Readme
hast-util-insert
A hast utility to insert nodes into a tree, at a location in the tree that is specified by a selector string.
Install
This package is ESM only.
Install with npm:
npm install hast-util-insert
In Deno with esm.sh:
import hastUtilInsert from "https://esm.sh/hast-util-insert@1";
In browsers with esm.sh:
Use
import { h } from "hastscript";
import {insert} from "hast-util-insert";
const tree = h("div", [h(".planet", "Jupiter")]);
hastUtilInsert(tree, ".planet", h("b", "inserted bold tag"), "append");
console.log(inspect(tree));