Miss any of our Open RFC calls?Watch the recordings here! »

clean-html-js

1.2.0 • Public • Published

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

param default type description
html "" string Optional: html string, can skip if url param is supplied
url "" string Optional: url of the html source to prevent fetching extra resources
config {} Config Optional: config object

Config

merges with config

prop default type description
allowedTags null array of strings html elements allowed
nonTextTags null array of strings html elements that should not be treated as text

allowedTags currently does not support svgs

Install

npm i clean-html-js

DownloadsWeekly Downloads

72

Version

1.2.0

License

MIT

Unpacked Size

16.8 kB

Total Files

16

Last publish

Collaborators

  • avatar