# scan-a-html-file

> Developing 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.2** (published 2018-03-18) · 0 weekly downloads

## Install

```sh
npm install scan-a-html-file
pnpm add scan-a-html-file
yarn add scan-a-html-file
bun add scan-a-html-file
```

## 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.2 |
| Published | 2018-03-18 |
| First published | 2018-03-16 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 13 |
| Unpacked size | 25.5 KB |
| Known vulnerabilities | 0 (+6 in 4 direct dependencies) |
| Install scripts | no |
| Maintainers | nguyenchathien |

## Links

- npm: https://www.npmjs.com/package/scan-a-html-file
- npm.io page: https://npm.io/package/scan-a-html-file

## Dependencies (13)

- [fs](https://npm.io/package/fs.md) 0.0.1-security
- [jade](https://npm.io/package/jade.md) ~1.11.0
- [when](https://npm.io/package/when.md) ^3.7.8
- [debug](https://npm.io/package/debug.md) ~2.6.9
- [dotenv](https://npm.io/package/dotenv.md) ^5.0.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.5
- [morgan](https://npm.io/package/morgan.md) ~1.9.0
- [express](https://npm.io/package/express.md) ~4.15.5
- [underscore](https://npm.io/package/underscore.md) ^1.8.3
- [body-parser](https://npm.io/package/body-parser.md) ~1.18.2
- [htmlparser2](https://npm.io/package/htmlparser2.md) ^3.9.2
- [cookie-parser](https://npm.io/package/cookie-parser.md) ~1.4.3
- [serve-favicon](https://npm.io/package/serve-favicon.md) ~2.4.5

## Recent versions

- 1.0.2 (latest) — 2018-03-18
- 1.0.1 — 2018-03-17
- 1.0.0 — 2018-03-16
- 0.0.0 — 2018-03-16

## README

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

# Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

# Installation
Install Scanning HTML file SEO defects globally using npm:
npm install --save scan-a-html-file

# Example
To get familiar with usage of the module:
node index.js

Output should be printed to terminal like below:

**************** Show all of the SEO defects *******************
All <img> in this HTML file contain attribute "alt".
This HTML file contains 30 <a> tag without rel attribute.
This HTML file does not have a <meta name="description" .../> tag
This HTML file does not have a <meta name="keywords" .../> tag
This HTML has less than 15, <strong> tag. Count = 0
This HTML has less than 1, <h1> tag. Count = 0

# Usage
The input can be either:
I. A HTML file (User is able to config the input path)
II. Node Readable Stream

The output can be either:
I. A file (User is able to config the output destination)
II. Node Writable Stream
III. Console

#configuration
# files
INPUT_FILE_PATH=/public/files/inputs/index.html
OUTPUT_FILE_PATH=/public/files/outputs/output.txt
OUTSREAM_FILE_PATH=/public/files/outputs/outstream.txt

# constant
STRONG_LIMIT=15

# Basic usage
1. Input file:
/**
 * Setup The input is A HTML file from the path
 * @param {object} input - used to feed in HTML file source
 */
scanHtmlFile.setInput(new Input().createInputFile(__dirname+"/test/Node.js.html"));

/**
 * Setup the output is console
 * @param {object} output - console
 */
scanHtmlFile.setOutput(new Output().createOutputConsole());

2. Input readable stream:
/**
 * Setup the input is A Node Readable Stream
 * @param {object} input - used to feed in HTML file source
 */
var readable_stream = fs.createReadStream(__dirname+"/test/Node.js.html");
scanHtmlFile.setInput(new Input().createInputStream(readable_stream));

3. Output to console:
/**
 * Setup the output is console
 * @param {object} output - console
 */
scanHtmlFile.setOutput(new Output().createOutputConsole());

4. Output to a file:
/**
 * Setup the output is a file
 * @param {object} output - used to feed in HTML file source
 */
scanHtmlFile.setOutput(new Output().createOutputFile(__dirname+"/output.txt"));

5. Output to readable stream:
/**
 * Setup the output is A Node Readable Stream
 * @param {object} output - used to feed in HTML file source
 */
var writeable_stream = fs.createWriteStream(__dirname + '/outstream.txt')
scanHtmlFile.setOutput(new Output().createOutputStream(writeable_stream));

6. Pre-defined SEO rules:
var rules = {
    img: 'alt', // if there are any <img />tags without alt attribute
    a: 'rel', // if there are any <a />tags without rel attribute
    head: {
        title: true, // if there is any header that doesn’t have <title>tag
        meta: ["description", "robots", "keywords"], // If you want to implement additional rule for meta tag, you just need to add a new tag to array.
    },
    strong: 15, // there are more than 15 <strong>tag in HTML
    h1: 1, // if a HTML have more than one <H1>tag
};

#License
This project is licensed under the MIT License - see the LICENSE file for details.

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