utility to transform hast to Parse5’s AST
Installations
npm install hast-util-to-parse5
Developer
Developer Guide
Module System
ESM
Min. Node Version
Typescript Support
Yes
Node Version
20.0.0
NPM Version
9.7.2
Statistics
2 Stars
120 Commits
2 Forks
9 Watching
1 Branches
11 Contributors
Updated on 31 Jan 2023
Bundle Size
20.23 kB
Minified
6.82 kB
Minified + Gzipped
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
712,399,241
Last day
-0.8%
655,991
Compared to previous day
Last week
2.4%
3,374,396
Compared to previous week
Last month
11.4%
14,312,271
Compared to previous month
Last year
-20%
168,567,657
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
hast-util-to-parse5
hast utility to transform to a parse5
AST.
Contents
- What is this?
- When should I use this?
- Install
- Use
- API
- Types
- Compatibility
- Security
- Related
- Contribute
- License
What is this?
This package is a utility that can turn a hast syntax tree into a parse5
AST.
Why not use a Parse5 adapter, you might ask?
Well, because it’s more code weight to use adapters, and more fragile.
When should I use this?
This package is useful when working with parse5
, and for some reason want to
generate its AST again.
The inverse utility, hast-util-from-parse5
, is more
likely what you want.
Install
This package is ESM only. In Node.js (version 16+), install with npm:
1npm install hast-util-to-parse5
In Deno with esm.sh
:
1import {toParse5} from 'https://esm.sh/hast-util-to-parse5@8'
In browsers with esm.sh
:
1<script type="module"> 2 import {toParse5} from 'https://esm.sh/hast-util-to-parse5@8?bundle' 3</script>
Use
1import {toParse5} from 'hast-util-to-parse5' 2 3const tree = toParse5({ 4 type: 'element', 5 tagName: 'h1', 6 properties: {}, 7 children: [{type: 'text', value: 'World!'}] 8}) 9 10console.log(tree)
Yields:
1{ nodeName: 'h1', 2 tagName: 'h1', 3 attrs: [], 4 namespaceURI: 'http://www.w3.org/1999/xhtml', 5 childNodes: [ { nodeName: '#text', value: 'World!', parentNode: [Circular] } ] }
API
This package exports the identifier toParse5
.
There is no default export.
toParse5(tree[, options])
Transform a hast tree to a parse5
AST.
Parameters
Returns
parse5
node (Parse5Node
).
Options
Configuration (TypeScript type).
Fields
space
(Space
, optional) — which space the document is in
Space
Namespace (TypeScript type).
Type
1type Space = 'html' | 'svg'
Types
This package is fully typed with TypeScript.
It exports the additional types Options
and
Space
.
Compatibility
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-to-parse5@^8
,
compatible with Node.js 16.
Security
Use of hast-util-to-parse5
can open you up to a
cross-site scripting (XSS) attack if the hast tree is unsafe.
Related
hast-util-from-parse5
— transform from Parse5’s AST to hasthast-util-to-nlcst
— transform hast to nlcsthast-util-to-mdast
— transform hast to mdasthast-util-to-xast
— transform hast to xastmdast-util-to-hast
— transform mdast to hastmdast-util-to-nlcst
— transform mdast to nlcst
Contribute
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.
License
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: license:0
- Info: FSF or OSI recognized license: MIT License: license:0
Reason
security policy file detected
Details
- Info: security policy file detected: github.com/syntax-tree/.github/security.md:1
- Info: Found linked content: github.com/syntax-tree/.github/security.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: github.com/syntax-tree/.github/security.md:1
- Info: Found text in security policy: github.com/syntax-tree/.github/security.md:1
Reason
Found 1/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
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/bb.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/syntax-tree/hast-util-to-parse5/bb.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/syntax-tree/hast-util-to-parse5/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/syntax-tree/hast-util-to-parse5/main.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/syntax-tree/hast-util-to-parse5/main.yml/main?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/main.yml:15
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 2 third-party GitHubAction dependencies pinned
- Info: 0 out of 1 npmCommand dependencies pinned
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/bb.yml:1
- Warn: no topLevel permission defined: .github/workflows/main.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
Project has not signed or included provenance with any releases.
Details
- Warn: release artifact 6.0.0 not signed: https://api.github.com/repos/syntax-tree/hast-util-to-parse5/releases/27603561
- Warn: release artifact 5.1.2 not signed: https://api.github.com/repos/syntax-tree/hast-util-to-parse5/releases/24067569
- Warn: release artifact 6.0.0 does not have provenance: https://api.github.com/repos/syntax-tree/hast-util-to-parse5/releases/27603561
- Warn: release artifact 5.1.2 does not have provenance: https://api.github.com/repos/syntax-tree/hast-util-to-parse5/releases/24067569
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 1 are checked with a SAST tool
Score
3.7
/10
Last Scanned on 2024-11-18
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