# npm-seo-def

> A Node.js package to let a user use this package to scan a HTML file and show all of the SEO defects

Latest version **1.0.1** (published 2018-03-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install npm-seo-def
pnpm add npm-seo-def
yarn add npm-seo-def
bun add npm-seo-def
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2018-03-14 |
| First published | 2018-03-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 31.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Kirity Mahanty |
| Maintainers | kirity714 |
| Keywords | parser, seo, seo-defects, rule, html |

## Links

- npm: https://www.npmjs.com/package/npm-seo-def
- Repository: https://github.com/kiritym/npm-seo-def
- Homepage: https://github.com/kiritym/npm-seo-def#readme
- Issues: https://github.com/kiritym/npm-seo-def/issues
- npm.io page: https://npm.io/package/npm-seo-def

## Dependencies (2)

- [cheerio](https://npm.io/package/cheerio.md) ^1.0.0-rc.2
- [htmlparser2](https://npm.io/package/htmlparser2.md) ^3.9.2

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2018-03-14
- 1.0.0 — 2018-03-14

## README

# npm-seo-def

> A Node.js package to let a user use this package to scan a HTML file and show all of the SEO defects

## Installation

Install the package globally using npm:

```bash
$ npm install -g npm-seo-def

```

Install the package locally using npm:

```bash
$ npm install npm-seo-def

```


## Usage
```js
var HtmlParser = require('npm-seo-def');

//1. read from input file and outputs on console with default rules
var htmlParser = new HtmlParser({}, "inputfile.html");
htmlParser.parseFile()

//2. read from input file and outputs on console with custom rules
var rules = [{
               "tag":"img",
               "params":{
                   "attribute":{
                     "name": "height",
                     "present": false
                   }
                }
              },
              {
                 "tag":"a",
                 "params":{
                     "attribute":{
                       "name": "rel",
                       "present": true
                     }
                 }
               }];
var htmlParser1 = new HtmlParser(rules, "inputfile.html");
htmlParser1.parseFile()

//3. read from input file and outputs in an output file
var htmlParser2 = new HtmlParser({}, "inputfile.html", 'out.txt');
htmlParser2.parseFile()

//4. read from readable stream and outputs in an output file
var fs = require('fs');
var s = fs.createReadStream("inputfile.html");
var htmlParser3 = new HtmlParser({}, s, 'out1.txt');
htmlParser3.parseStream(s);

```

## How to write custom rules

 - Detect the number of `<img />` tags `without` `alt` attribute
```js
{
    "tag":"img",
    "params":{
        "attribute":{
          "name": "alt",
          "present": false
        },
    }
}
```

- Detect the number of `<img />` tags `with` `alt` attribute
```js
{
   "tag":"img",
   "params":{
       "attribute":{
         "name": "alt",
         "present": true
       },
   }
}
```

- Detect if there are more than <b>5</b> `<strong>` tag in HTML
```js
{
  "tag":"strong",
  "params":{
    "min_count": 5
  }
}
```

- Detect if there is any header that doesn’t have `<title>` tag
```js
{
  "tag":"head",
  "params":{
    "child":[{
              "tag":"title",
              "present": false
            }]
     }
 }
```

- Detect if there is any header that does have `<title>` tag
```js
{
  "tag":"head",
  "params":{
    "child":[{
              "tag":"title",
              "present": true
            }]
     }
 }
```

- Detect if there is any header that doesn’t have `<meta name=“descriptions” ... />` tag
```js
{
  "tag":"head",
  "params":{
    "child":[
              {
                "tag":"meta",
                "present": false,
                "name": "descriptions"
              }
            ]
     }
 }
```




## Development & Testing

Clone the repository and install it:

```bash
$ git clone https://github.com/kiritym/npm-seo-def.git
$ cd npm-seo-def
$ npm install
```

Run the test cases:

```bash
$ npm test
```

---
_Source: https://npm.io/package/npm-seo-def · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
