All Projects β†’ fb55 β†’ Domhandler

fb55 / Domhandler

Licence: bsd-2-clause
Handler for htmlparser2, to get a DOM

Programming Languages

typescript
32286 projects

Labels

Projects that are alternatives of or similar to Domhandler

Nanomorph
πŸš… - Hyper fast diffing algorithm for real DOM nodes
Stars: ✭ 621 (+205.91%)
Mutual labels:  tree, dom
AdvancedHTMLParser
Fast Indexed python HTML parser which builds a DOM node tree, providing common getElementsBy* functions for scraping, testing, modification, and formatting. Also XPath.
Stars: ✭ 90 (-55.67%)
Mutual labels:  tree, dom
js-symbol-tree
Turn any collection of objects into its own efficient tree or linked list using Symbol
Stars: ✭ 86 (-57.64%)
Mutual labels:  tree, dom
Object Visualizer
Vue JSON inspector with Chrome-like theme.
Stars: ✭ 159 (-21.67%)
Mutual labels:  tree, dom
Simple Element Resize Detector
Observes element size changes using a hidden iframe
Stars: ✭ 187 (-7.88%)
Mutual labels:  dom
Leetcode
High-quality LeetCode solutions
Stars: ✭ 178 (-12.32%)
Mutual labels:  tree
Treeify
Pretty-print a javascript object as a tree
Stars: ✭ 174 (-14.29%)
Mutual labels:  tree
Vue Tree
vue element-ui tree component expand
Stars: ✭ 172 (-15.27%)
Mutual labels:  tree
Outwiker
Π‘ross-platform software for keeping your notes in a tree
Stars: ✭ 198 (-2.46%)
Mutual labels:  tree
Phantomas
Headless Chromium-based web performance metrics collector and monitoring tool
Stars: ✭ 2,191 (+979.31%)
Mutual labels:  dom
Orgchart
It's a simple and direct organization chart plugin. Anytime you want a tree-like chart, you can turn to OrgChart.
Stars: ✭ 2,325 (+1045.32%)
Mutual labels:  tree
Val
VirtualDOM abstraction layer - give yourself better integration and full control over the DOM with any virtual DOM library that uses a Hyperscript-like API such as React and Preact.
Stars: ✭ 181 (-10.84%)
Mutual labels:  dom
Interview Questions
List of all the Interview questions practiced from online resources and books
Stars: ✭ 187 (-7.88%)
Mutual labels:  tree
Deepdash
eachDeep, filterDeep, findDeep, someDeep, omitDeep, pickDeep, keysDeep etc.. Tree traversal library written in Underscore/Lodash fashion
Stars: ✭ 175 (-13.79%)
Mutual labels:  tree
Fast
Find in AST - Search and refactor code directly in Abstract Syntax Tree as you do with grep for strings
Stars: ✭ 194 (-4.43%)
Mutual labels:  tree
Jquery Xpath
jQuery XPath plugin (with full XPath 2.0 language support)
Stars: ✭ 173 (-14.78%)
Mutual labels:  dom
Online Privacy Test Resource List
Privacy Online Test and Resource Compendium (POTARC) πŸ•΅πŸ»
Stars: ✭ 185 (-8.87%)
Mutual labels:  dom
React Vtree
React component for efficiently rendering large tree structures
Stars: ✭ 185 (-8.87%)
Mutual labels:  tree
Vue Orgchart
It's a simple and direct organization chart plugin. Anytime you want a tree-like chart, you can turn to OrgChart.
Stars: ✭ 182 (-10.34%)
Mutual labels:  tree
Domxssscanner
DOMXSS Scanner is an online tool to scan source code for DOM based XSS vulnerabilities
Stars: ✭ 181 (-10.84%)
Mutual labels:  dom

domhandler Build Status

The DOM handler creates a tree containing all nodes of a page. The tree can be manipulated using the domutils or cheerio libraries and rendered using dom-serializer .

Usage

const handler = new DomHandler([ <func> callback(err, dom), ] [ <obj> options ]);
// const parser = new Parser(handler[, options]);

Available options are described below.

Example

const { Parser } = require("htmlparser2");
const { DomHandler } = require("domhandler");
const rawHtml =
    "Xyz <script language= javascript>var foo = '<<bar>>';< /  script><!--<!-- Waah! -- -->";
const handler = new DomHandler(function (error, dom) {
    if (error) {
        // Handle error
    } else {
        // Parsing completed, do something
        console.log(dom);
    }
});
const parser = new Parser(handler);
parser.write(rawHtml);
parser.end();

Output:

[
    {
        data: "Xyz ",
        type: "text",
    },
    {
        type: "script",
        name: "script",
        attribs: {
            language: "javascript",
        },
        children: [
            {
                data: "var foo = '<bar>';<",
                type: "text",
            },
        ],
    },
    {
        data: "<!-- Waah! -- ",
        type: "comment",
    },
];

Option: withStartIndices

Add a startIndex property to nodes. When the parser is used in a non-streaming fashion, startIndex is an integer indicating the position of the start of the node in the document. The default value is false.

Option: withEndIndices

Add an endIndex property to nodes. When the parser is used in a non-streaming fashion, endIndex is an integer indicating the position of the end of the node in the document. The default value is false.

Option: normalizeWhitespace (deprecated)

Replace all whitespace with single spaces. The default value is false.

Note: Enabling this might break your markup.

For the following examples, this HTML will be used:

<font> <br />this is the text <font></font></font>

Example: normalizeWhitespace: true

[
    {
        type: "tag",
        name: "font",
        children: [
            {
                data: " ",
                type: "text",
            },
            {
                type: "tag",
                name: "br",
            },
            {
                data: "this is the text ",
                type: "text",
            },
            {
                type: "tag",
                name: "font",
            },
        ],
    },
];

Example: normalizeWhitespace: false

[
    {
        type: "tag",
        name: "font",
        children: [
            {
                data: "\n\t",
                type: "text",
            },
            {
                type: "tag",
                name: "br",
            },
            {
                data: "this is the text\n",
                type: "text",
            },
            {
                type: "tag",
                name: "font",
            },
        ],
    },
];

License: BSD-2-Clause

Security contact information

To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.

domhandler for enterprise

Available as part of the Tidelift Subscription

The maintainers of domhandler and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].