Socket
Socket
Sign inDemoInstall

parse5-htmlparser2-tree-adapter

Package Overview
Dependencies
4
Maintainers
4
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Protect your apps from supply chain attacks

Install

parse5-htmlparser2-tree-adapter

htmlparser2 tree adapter for parse5.

    7.0.0latest
    GitHub
    npm

Version published
Maintainers
4
Weekly downloads
9,450,337
increased by3.36%

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 installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the 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