html-objectifier

1.1.3 • Public • Published

html-objectifier

This Node.js package allows you to effortlessly convert HTML markup into a structured JavaScript object. It's a versatile library that can be used in both Node.js applications and browser environments. Whether you need to process HTML from files or input via a textarea, this library has you covered.

Features

  • Parse HTML markup into a nested object structure.
  • Extract tag names, attributes, text content, and styles.
  • Handle complex nested HTML elements and structures.
  • Designed for ease of use with CLI and browser input support.
  • Highly customizable with options for parsing and formatting.

Installation

You can install this package using npm or yarn:

npm install html-objectifier
# or
yarn add html-objectifier

Usage

  1. Import the library in your Node.js application:
//index.js

const html_objectifier = require("html-objectifier");
html_objectifier();
  1. You can run it as CLI by running node index.js markup.html

  2. Use the library to convert HTML to an object:

const html = "<div><p>Hello, World!</p></div>";
const result = html_objectifier.parseHTML(html);
console.log(JSON.stringify(result));

For browser usage, include the library via a script tag and use it in your JavaScript code.

<script src="https://cdn.jsdelivr.net/gh/byteballet/html-objectifier@master/dist/bundled.js"></script>
<script>
  const { parseHTML } = html_objectifier;
  console.log(parseHTML('<!DOCTYPE html><html lang="en"></html>'));
</script>

Contributions

Contributions and feedback are welcome! If you have suggestions, bug reports, or want to contribute code, please open an issue or submit a pull request.

License

This package is open-source.

Author

[Byte Ballet]

Contact

For inquiries, Talk to Me!.

Readme

Keywords

Package Sidebar

Install

npm i html-objectifier

Weekly Downloads

0

Version

1.1.3

License

ISC

Unpacked Size

9.01 kB

Total Files

6

Last publish

Collaborators

  • byteballet