didou           Sat Feb  3 19:03:35 2007 UTC

  Modified files:              
    /phpdoc/scripts     html_syntax.php 
  Log:
  Add callback_highlight_xml
  
http://cvs.php.net/viewvc.cgi/phpdoc/scripts/html_syntax.php?r1=1.8&r2=1.9&diff_format=u
Index: phpdoc/scripts/html_syntax.php
diff -u phpdoc/scripts/html_syntax.php:1.8 phpdoc/scripts/html_syntax.php:1.9
--- phpdoc/scripts/html_syntax.php:1.8  Thu Feb  1 14:51:15 2007
+++ phpdoc/scripts/html_syntax.php      Sat Feb  3 19:03:35 2007
@@ -39,6 +39,44 @@
        }
 }
 
+function callback_highlight_xml($matches) {
+        $color = array(
+        'attributes' => '#333366',
+        'tags' => '#000066',
+        'comment' => '#666666',
+        'keyword' => '#cc6600',
+        'string' => '#006600',
+        'cdata' => '#990000',
+        );
+
+        $source = htmlentities($matches[1]);
+
+        $match = array(
+            '/(\w+)=("|"|\')(.*?)("|"|\')/',
+            '/!DOCTYPE (\w+) (\w+) ("|\'|")(.*?)("|\'|")/',
+            '/<([a-zA-Z_][a-zA-Z0-9_:-]*)/',
+            '/<\/([a-zA-Z_][a-zA-Z0-9_:-]*)>/',
+            '/<!--/',
+            '/-->/',
+            '/<\?xml (.*?) ?\?>/i',
+            '/<!\[CDATA\[(.*)\]\]>/i',
+        );
+
+
+        $replace = array(
+            '<span style="color: ' .$color['attributes']. '">$1</span>=<span 
style="color: ' .$color['string']. '">$2$3$2</span>',
+            '<span style="color: ' .$color['tags']. ';">!DOCTYPE</span> <span 
style="color: ' .$color['attributes']. '">$1 $2 $3$4$3</span>',
+            '&lt;<span style="color: ' .$color['tags']. ';">$1</span>',
+            '&lt;/<span style="color: ' .$color['tags']. ';">$1</span>&gt;',
+            '<span style="color: ' .$color['comment']. '"><!--',
+            '--&gt;</span>',
+            '&lt;<span style="color: ' .$color['tags']. ';">?xml</span> $1 
<span style="color: ' .$color['tags']. ';">?</span>&gt;',
+            '<span style="color: ' .$color['tags']. ';">&lt;![<span 
style="color: ' . $color['keyword']. '">CDATA</span>[</span><span style="color: 
' .$color['cdata']. ';">$1</span><span style="color: ' .$color['tags']. 
';">]]&gt;</span>'
+        );
+
+        return preg_replace($match, $replace, $source);
+}
+
 $files = $_SERVER["argv"];
 array_shift($files); // $argv[0] - script filename
 $TYPE = array_shift($files); // "html" or "php"

Reply via email to