Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/webchemistry/html-purifier

simple html-purifier
https://github.com/webchemistry/html-purifier

Last synced: about 1 month ago
JSON representation

simple html-purifier

Awesome Lists containing this project

README

        

## Simple html purifier

Usage:

```php
$rules = new Rules();

$rules->addMulti(
ElementRule::create('i'),
ElementRule::create('div'),
ElementRule::create('strong')
->addAttributeRule(
AttributeRule::create('class')
->allowValue('italic')
),
ElementRule::create('script')
->discard(),
ElementRule::create('span')
->addAttributeRule(
AttributeStyleRule::create()
->addRule('color', ['white', '#fff', '#fffff'])
)
);

$purifier = new Purifier($rules);

$purifier->purify('


Lorem ipsum is simply

alert("dummy text!")

white and red




');
```

output:

```html


Lorem ipsum is simply

white and red

```