Last active
September 26, 2015 04:17
-
-
Save pkdavies/1037649 to your computer and use it in GitHub Desktop.
MS Word "save as HTML" and HTML Purifier
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ($_POST['q']){ | |
$dirty_html = $_POST['q']; | |
if (!$dirty_html) { | |
echo ('You must write some HTML!'); | |
} else { | |
$config = HTMLPurifier_Config::createDefault(); | |
$config->set('Core', 'Encoding', 'ISO-8859-1'); | |
$config->set('HTML', 'Doctype', 'XHTML 1.0 Transitional'); | |
$config->set('HTML', 'TidyLevel', 'heavy'); | |
$config->set('Core','AcceptFullDocuments',true); | |
$config->set('HTML', 'Allowed', 'a[href|title],em,p,blockquote,img'); | |
$purifier = new HTMLPurifier($config); | |
$clean_html = $purifier->purify( $dirty_html ); | |
echo $clean_html; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment