Socket
Socket
Sign inDemoInstall

parse5-htmlparser2-tree-adapter

Package Overview
Dependencies
4
Maintainers
4
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    parse5-htmlparser2-tree-adapter

htmlparser2 tree adapter for parse5.


Version published
Weekly downloads
9.5M
increased by2.83%
Maintainers
4
Install size
1.47 MB
Created
Weekly downloads
 

Package description

What is parse5-htmlparser2-tree-adapter?

The parse5-htmlparser2-tree-adapter package is an adapter that allows parse5 to use the tree structure and node types defined by the htmlparser2 library. This enables users to switch between parse5's default tree adapter and the htmlparser2-compatible one without changing the underlying parsing logic.

What are parse5-htmlparser2-tree-adapter's main functionalities?

Converting parse5's default tree structure to htmlparser2 tree structure

This feature allows users to parse HTML content using parse5 with the tree structure compatible with htmlparser2. The code sample demonstrates how to parse a simple HTML string and access the parsed tree using htmlparser2's node naming conventions.

const parse5 = require('parse5');
const htmlparser2Adapter = require('parse5-htmlparser2-tree-adapter');

const document = parse5.parse('<div>Example</div>', { treeAdapter: htmlparser2Adapter });
console.log(document.childNodes[0].name); // 'div'

Serializing htmlparser2 tree structure back to HTML

This feature allows users to serialize the htmlparser2 tree structure back into HTML. The code sample shows how to parse an HTML string and then serialize the resulting document object back to an HTML string.

const parse5 = require('parse5');
const htmlparser2Adapter = require('parse5-htmlparser2-tree-adapter');

const document = parse5.parse('<div>Example</div>', { treeAdapter: htmlparser2Adapter });
const serializedHtml = parse5.serialize(document, { treeAdapter: htmlparser2Adapter });
console.log(serializedHtml); // '<div>Example</div>'

Other packages similar to parse5-htmlparser2-tree-adapter

Readme

Source

parse5

parse5-htmlparser2-tree-adapter

htmlparser2 tree adapter for parse5.

npm install --save parse5-htmlparser2-tree-adapter

📖 Documentation 📖


List of parse5 toolset packages

GitHub

Changelog

Keywords

FAQs

Last updated on 20 Apr 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc