Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hast-util-from-parse5

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hast-util-from-parse5

hast utility to transform from a `parse5` AST

  • 8.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is hast-util-from-parse5?

The `hast-util-from-parse5` package is a utility that converts a Parse5 AST (Abstract Syntax Tree) to a HAST (Hypertext Abstract Syntax Tree). This is particularly useful for working with HTML in a structured way, allowing for transformations, analysis, and manipulation of HTML content.

What are hast-util-from-parse5's main functionalities?

Convert Parse5 AST to HAST

This feature allows you to convert a Parse5 AST to a HAST. The code sample demonstrates parsing an HTML string into a Parse5 AST and then converting it to a HAST.

const parse5 = require('parse5');
const fromParse5 = require('hast-util-from-parse5');

const html = '<!doctype html><html><head><title>Example</title></head><body><p>Hello, world!</p></body></html>';
const parse5Ast = parse5.parse(html);
const hast = fromParse5(parse5Ast);

console.log(JSON.stringify(hast, null, 2));

Convert Parse5 Fragment to HAST

This feature allows you to convert a Parse5 fragment to a HAST. The code sample demonstrates parsing an HTML fragment into a Parse5 fragment and then converting it to a HAST.

const parse5 = require('parse5');
const fromParse5 = require('hast-util-from-parse5');

const htmlFragment = '<p>Hello, world!</p>';
const parse5Fragment = parse5.parseFragment(htmlFragment);
const hastFragment = fromParse5(parse5Fragment);

console.log(JSON.stringify(hastFragment, null, 2));

Other packages similar to hast-util-from-parse5

Keywords

FAQs

Package last updated on 19 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc