Gathering detailed insights and metrics for hast-util-from-dom
Gathering detailed insights and metrics for hast-util-from-dom
Gathering detailed insights and metrics for hast-util-from-dom
Gathering detailed insights and metrics for hast-util-from-dom
npm install hast-util-from-dom
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
ISC License
22 Stars
104 Commits
4 Forks
8 Watchers
1 Branches
11 Contributors
Updated on Nov 19, 2024
Latest Version
5.0.1
Package Id
hast-util-from-dom@5.0.1
Unpacked Size
15.99 kB
Size
5.57 kB
File Count
9
NPM Version
10.9.0
Node Version
23.1.0
Published on
Nov 19, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
hast utility to transform from a DOM tree.
This package is a utility that takes a DOM tree (from the actual DOM or from
things like jsdom
) as input and turns it into a hast (HTML)
syntax tree.
You can use this project when you want to use hast in browsers. This package is very small, but it does so by:
The hast utility hast-util-to-dom
does the inverse of this
utility.
It turns hast into a DOM tree.
The rehype plugin rehype-dom-parse
wraps this utility to
parse HTML with DOM APIs.
This package is ESM only. In Node.js (version 16+), install with npm:
1npm install hast-util-from-dom
In Deno with esm.sh
:
1import {fromDom} from 'https://esm.sh/hast-util-from-dom@5'
In browsers with esm.sh
:
1<script type="module"> 2 import {fromDom} from 'https://esm.sh/hast-util-from-dom@5?bundle' 3</script>
Say our page example.html
looks as follows:
1<!doctype html> 2<title>Example</title> 3<body> 4 <main> 5 <h1>Hi</h1> 6 <p><em>Hello</em>, world!</p> 7 </main> 8 <script type="module"> 9 import {fromDom} from 'https://esm.sh/hast-util-from-dom@4?bundle' 10 11 const hast = fromDom(document.querySelector('main')) 12 13 console.log(hast) 14 </script>
Now running open example.html
prints the following to the console:
1{type: "element", tagName: "main", properties: {}, children: Array}
This package exports the identifier fromDom
.
There is no default export.
fromDom(tree, options?)
Transform a DOM tree to a hast tree.
Equivalent hast node (HastNode
).
AfterTransform
Callback called when each node is transformed (TypeScript type).
Nothing.
Options
Configuration (TypeScript type).
afterTransform
(AfterTransform
, optional)
— callback called when each node is transformedThis package is fully typed with TypeScript.
It exports the additional types AfterTransform
and
Options
.
Projects maintained by the unified collective are compatible with maintained versions of Node.js.
When we cut a new major release, we drop support for unmaintained versions of
Node.
This means we try to keep the current release line, hast-util-from-dom@^5
,
compatible with Node.js 16.
Use of hast-util-from-dom
itself is safe but see other utilities for more
information on potential security problems.
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, organisation, or community you agree to abide by its terms.
hast-util-from-html
— parse hast from a string of HTMLhast-util-sanitize
— sanitize hast nodeshast-util-to-html
— serialize hast as HTMLhast-util-to-dom
— create DOM trees from hastNo vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More