New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

html-to-object-parser

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-to-object-parser

A library for parsing HTML into objects

  • 1.0.0
  • unpublished
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

HTML to Object Parser

This is a JavaScript library that converts HTML into a structured JavaScript object.

Installation

First, clone this repository:

git clone git@github.com:thomasdonnelly0114/symbol_test.git
cd symbol_test

Next, install the required dependencies:

yarn install

Usage

You can use the library in your Node.js code as follows:

const { htmlToObject } = require('./htmlToObject');

const html = `
  <div style="background-color: yellow; font-size: 14px" id="first-div">
    Hello, friends
    <p class="para" style="font-family: monospace; font-size: 11px">Lorem ipsum dolor sit</p>
    <footer style="width: auto; height: 100px; color: blue">
      <span>This is the end</span>
    </footer>
  </div>
`;

const result = htmlToObject(html);

console.log(result);

Running Tests

You can run tests using Jest:

    npm test

Exmaple Output

The code will produce the following output for the provided HTML:

{
  "tag": "div",
  "text": "Hello, friends",
  "style": {
    "background-color": "yellow",
    "font-size": "14px"
  },
  "id": "first-div",
  "children": [
    {
      "tag": "p",
      "text": "Lorem ipsum dolor sit",
      "class": ["para"],
      "style": {
        "font-family": "monospace",
        "font-size": "11px"
      }
    },
    {
      "tag": "footer",
      "style": {
        "width": "auto",
        "height": "100px",
        "color": "blue"
      },
      "children": [{ "tag": "span", "text": "This is the end" }]
    }
  ]
}

Publish to npm

    npm publish

FAQs

Package last updated on 10 Sep 2023

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