Tidy 2 support banana-1.5
authorx2003bruneau <x2003bruneau@9869982d-c50d-0410-be91-f2a2ec7c7c7b>
Mon, 9 Apr 2007 21:43:01 +0000 (21:43 +0000)
committerx2003bruneau <x2003bruneau@9869982d-c50d-0410-be91-f2a2ec7c7c7b>
Mon, 9 Apr 2007 21:43:01 +0000 (21:43 +0000)
 message.func.inc.php |   37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)

git-svn-id: svn+ssh://murphy/home/svn/banana/branches/banana-1.5@231 9869982d-c50d-0410-be91-f2a2ec7c7c7b

banana/message.func.inc.php

index f0f8d93..e50023e 100644 (file)
@@ -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