New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

html-janitor

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-janitor - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

4

CHANGELOG.md

@@ -5,2 +5,6 @@ # HTML Janitor

## 1.0.1
PRE has been added to the list of block elements
## 1.0.0

@@ -7,0 +11,0 @@

2

package.json
{
"name": "html-janitor",
"version": "1.0.0",
"version": "1.0.1",
"main": "src/html-janitor.js",

@@ -5,0 +5,0 @@ "scripts": {

# html-janitor
Sanitises HTML.
Cleans up your markup and allows you to take control of your HTML.
HTMLJanitor uses a defined whitelist to limit HTML it is given to a defined subset.
![](https://circleci.com/gh/guardian/html-janitor.png?circle-token=bd24300ee650966837a73bfe03386828f0192c06)
## Usage
```
var janitor = HTMLJanitor(options);
var sanitisedHtml = janitor.clean(html);
```
### Options
A configuration object.
`tags` defines a whitelist of elements that are allowed in the sanitised output. Each entry in the map should be the name of the element and the attributes that a valid for the element.
E.g. `{tags: { p:{}, a: { href: true} }}` would limit the valid HTML subset to just paragraphs and anchor tags, the anchor tags would only have the `href` attribute preserved.
## Distribution
Uses UMD for support in AMD and Common JS environments.
### Not suitable for Node
This library is designed for use in a browser and requires access to [document](https://developer.mozilla.org/en/docs/Web/API/Document) and [createTreeWalker](https://developer.mozilla.org/en-US/docs/Web/API/Document/createTreeWalker) to work.
## Installation

@@ -10,0 +35,0 @@

@@ -20,3 +20,3 @@ (function (root, factory) {

// TODO: not exhaustive?
var blockElementNames = ['P', 'LI', 'TD', 'TH', 'DIV', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6'];
var blockElementNames = ['P', 'LI', 'TD', 'TH', 'DIV', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'PRE'];
function isBlockElement(node) {

@@ -23,0 +23,0 @@ return blockElementNames.indexOf(node.nodeName) !== -1;

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