1.3.16 • Published 3 years ago

clean-html-js v1.3.16

Weekly downloads
107
License
MIT
Repository
github
Last release
3 years ago

clean-html-js

A11yWatch

clean html content for reading. simply pass in your content as html and get a readability object

Installation Instructions

$ yarn add clean-html-js

Example

Alt Text

import cleanHtml from "clean-html-js";

const url = "https://www.a11ywatch.com";

async function grabReaderData() {
  const source = await fetch(url);
  const html = await source.text();
  const readabilityArticle = await cleanHtml(html, url);
}

async function grabReaderDataSimple() {
  const readabilityArticle = await cleanHtml("", url);
}

grabReaderData().then((data) => {
  console.log(data);
});

// or just the url
grabReaderDataSimple().then((data) => {
  console.log(data);
});
  • For more help getting started checkout Example

Available Params

paramdefaulttypedescription
html""stringRequired: html string to parse
sourceUrl""stringOptional: url of the html source to prevent fetching extra resources
config{}ConfigOptional: config object

If html is not provided and sourceUrl is found an attempt to fetch the html is done.

Config

merges with config

propdefaulttypedescription
allowedTagsnullarray of stringshtml elements allowed note:(svgs must be inlined)
nonTextTagsnullarray of stringshtml elements that should not be treated as text

Testing

to test custom pages pass in your params seperated by commas into the jest test example yarn jest '-params=mozilla,https://www.mozilla.com' or yarn jest '-params=a11ywatch,https://www.a11ywatch.com'. First param is the html file being pulled from the examples folder and the second is an optional uri for the resources.

  1. npm test
1.3.16

3 years ago

1.3.14

3 years ago

1.2.8

3 years ago

1.3.6

3 years ago

1.3.5

3 years ago

1.2.6

3 years ago

1.3.4

3 years ago

1.2.5

3 years ago

1.3.3

3 years ago

1.2.4

3 years ago

1.3.1

3 years ago

1.2.2

3 years ago

1.3.0

3 years ago

1.2.1

3 years ago

1.3.10

3 years ago

1.3.13

3 years ago

1.3.11

3 years ago

1.3.12

3 years ago

1.3.9

3 years ago

1.3.8

3 years ago

1.2.9

3 years ago

1.2.0

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago