Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

advanced-html-parser

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

advanced-html-parser - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

test/speedTest.js

6

components/dom-parser.js

@@ -15,2 +15,8 @@ function DOMParser(options) {

var entityMap = options.entityMap || {};
if (options.ignoreTags && options.ignoreTags.length>0){
var expression = `<(${options.ignoreTags.join("|")})(.*?)>(.|\n)*?<\/(${options.ignoreTags.join("|")})>`;
console.log("Found ignoreTags executing", expression)
source = source.replace(new RegExp(expression, "gmi"), "");
}
if (typeof require == 'function') {

@@ -17,0 +23,0 @@ const enMap = require('./entity-map').EntityMap;

2

index.d.ts

@@ -5,3 +5,3 @@

export declare namespace IDomParser {
const parse: (html: string, mimeType?: string, options?: Options) => Document;
const parse: (html: string, options?: Options) => Document;
const serializeToString: (node: Node, attributeSorter?: any) => string;

@@ -8,0 +8,0 @@ }

@@ -5,3 +5,3 @@ const DOMParser = require("./components/dom-parser").DOMParser;

const IDomParser = {
parse: (html, mimeType, options) => new DOMParser(options).parseFromString(html, mimeType),
parse: (html, options) => new DOMParser(options).parseFromString(html, options),
serializeToString: (node, attributeSorter) => new XMLSerializer().serializeToString(node, attributeSorter)

@@ -8,0 +8,0 @@ }

{
"name": "advanced-html-parser",
"version": "1.0.5",
"version": "1.0.6",
"description": "Can use html parser in react-native, titanium, and anywhere. This is based on [xmldom](https://github.com/jindw/xmldom).",

@@ -32,3 +32,4 @@ "main": "index.js",

"test": "node test/test.js",
"mocha": "mocha test/test.js"
"mocha": "mocha test/test.js",
"speed": "mocha test/speedTest.js"
},

@@ -35,0 +36,0 @@ "dependencies": {

@@ -23,5 +23,16 @@ # advanced-html-parser

## CSS3 Selector support
The library uses [css-select](https://github.com/fb55/css-select) and it support everything css-select uses
The library uses `css-select` and it support all advanced selectors `css-select` support like
`#info > .description > .small strong:first-child span` and more.
See [css-select](https://github.com/fb55/css-select) for more info.
## Speed up the parsing
The libray is very fast, and if you want to use it to scrap some data from website. then using the settings below may speed the parsing.
```js
const doc = IDOMParser.parse(page, {
ignoreTags: ["script", "style", "head"] // This will remove all those tags before begining to parse the string.
});
```
## Node Class

@@ -130,2 +141,24 @@ ```ts

}
```
## Parser Options
```ts
export interface Options {
xmlns?: { xml?: string };
/*
default text/html
*/
mimeType?: string;
/*
Ignore parsing tags eg script, style etc
This is for performance issue, will use RegExp to clean the html string before parsing it.
*/
ignoreTags?:string[];
}
```

@@ -25,2 +25,3 @@ const IDOMParser = require("./../")

describe("Reading clone", function () {

@@ -27,0 +28,0 @@ const doc = IDOMParser.parse(`<div>test</div>`);

@@ -7,2 +7,10 @@ export interface Options {

mimeType?: string;
/*
Ignore parsing tags eg script, style etc
This is for performance issue, will use RegExp to clean the html string before parsing it
*/
ignoreTags?:string[];
}

@@ -70,5 +78,4 @@

contains: (c: string) => boolean;
replace: (k1, k2) => void;
replace: (k1: string, k2: string) => void;
toString: () => string;
}

@@ -75,0 +82,0 @@

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