From 0321cbd884070b3d021b16c8ff32cd535987a86a Mon Sep 17 00:00:00 2001 From: x2003bruneau Date: Fri, 2 Feb 2007 10:05:56 +0000 Subject: [PATCH] Tidy 2.0 support git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@192 9869982d-c50d-0410-be91-f2a2ec7c7c7b --- banana/message.func.inc.php | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/banana/message.func.inc.php b/banana/message.func.inc.php index f0f8d93..e50023e 100644 --- a/banana/message.func.inc.php +++ b/banana/message.func.inc.php @@ -331,24 +331,27 @@ function banana_filterCss($css) */ function banana_cleanHtml($source, $to_xhtml = false) { - if (function_exists('tidy_repair_string')) { - $tidy_on = Array( - 'drop-empty-paras', 'drop-proprietary-attributes', - 'hide-comments', 'logical-emphasis', 'output-xhtml', - 'replace-color', - ); - $tidy_off = Array('join-classes', 'clean', 'show-body-only'); // 'clean' may be a good idea, but it is too aggressive - - foreach($tidy_on as $opt) { - tidy_setopt($opt, true); - } - foreach($tidy_off as $opt) { - tidy_setopt($opt, false); + if (!function_exists('tidy_repair_string')) { + $tidy_config = array('drop-empty-paras' => true, + 'drop-proprietary-attributes' => true, + 'hide-comments' => true, + 'logical-emphasis' => true, + 'output-xhtml' => true, + 'replace-color' => true, + 'join-classes' => false, + 'clean' => false, + 'show-body-only' => false, + 'alt-text' => '[ inserted by TIDY ]', + 'wrap' => 120); + if (function_exists('tidy_setopt')) { // Tidy 1.0 + foreach ($tidy_config as $field=>$value) { + tidy_setopt($field, $value); + } + tidy_set_encoding('utf8'); + $source = tidy_repair_string($source); + } else { // Tidy 2.0 + $source = tidy_repair_string($source, $tidy_config, 'utf8'); } - tidy_setopt('alt-text', '[ inserted by TIDY ]'); - tidy_setopt('wrap', '120'); - tidy_set_encoding('utf8'); - $source = tidy_repair_string($source); } // To XHTML -- 2.1.4