2017 © Pedro Peláez
 

library cleanhtml

Quickly & Easily clean out HTML text, making sure that only the bare minimum is left behind

image

timgws/cleanhtml

Quickly & Easily clean out HTML text, making sure that only the bare minimum is left behind

  • Friday, March 11, 2016
  • by timgws
  • Repository
  • 1 Watchers
  • 5 Stars
  • 74 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

CleanHTML

Test Coverage Code Climate, (*1)

Making HTML clean since late 2012!, (*2)

Requirements

  • PHP 5.2+
  • php-xml

How to install

    composer require timgws/cleanhtml

How to use


use timgws\CleanHTML\CleanHTML; $tidy = new CleanHTML(); $output = $tidy->clean(' < p><strong>I need a shower. I am dirty HTML.</strong>');

$output should now contain:, (*3)

<h2>I need a shower. I am dirty HTML.</h2>

Using the Clean function will remove tables, any Javascript or other non-friendly items that you might not want to see from user submitted HTML., (*4)

If you want to see some examples, the best place to look would be some of the CleanHTML test, (*5)

What does it do?

  1. Removed additional spaces from HTML
  2. Replaces multiple <br /> tags with paragraph tags
  3. Removes any <script> tags
  4. Renames any <h1> tags to <h2>
  5. Changes <p><strong> tags to <h2>
  6. Replaces <h2><strong> with just <h2> tags
  7. Removes weird <p><span> tags
  8. Uses HTML purifier to only allow h1,h2,h3,h4,h5,p,strong,b,ul,ol,li,hr,pre,code tags
  9. Runs steps 3->7 one more time, just to catch anything that might have missed by allowed tags
  10. Outputs nice clean HTML \o/

The Versions

11/03 2016

dev-master

9999999-dev http://github.com/timgws/CleanHTML

Quickly & Easily clean out HTML text, making sure that only the bare minimum is left behind

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel sql parser jquery eloquent ajax query builder