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

hast-util-from-dom

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hast-util-from-dom

hast utility to create a tree from the DOM

  • 5.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
364K
increased by4.73%
Maintainers
2
Weekly downloads
 
Created

What is hast-util-from-dom?

The `hast-util-from-dom` package is a utility for converting DOM nodes to HAST (Hypertext Abstract Syntax Tree) nodes. This is particularly useful for working with HTML content in a structured and programmatic way, enabling transformations, analysis, and rendering of HTML content.

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

Convert DOM to HAST

This feature allows you to convert a DOM node to a HAST node. In this example, we use `jsdom` to create a DOM from an HTML string and then convert a paragraph element to a HAST node.

const { fromDom } = require('hast-util-from-dom');
const jsdom = require('jsdom');
const { JSDOM } = jsdom;

const dom = new JSDOM('<!DOCTYPE html><p>Hello world</p>');
const hast = fromDom(dom.window.document.querySelector('p'));
console.log(hast);

Other packages similar to hast-util-from-dom

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