colder Sat Feb 3 22:57:46 2007 UTC
Modified files: /phpdoc/scripts html_syntax.php Log: -Indent the XML tree with 's - < needs to be < http://cvs.php.net/viewvc.cgi/phpdoc/scripts/html_syntax.php?r1=1.11&r2=1.12&diff_format=u Index: phpdoc/scripts/html_syntax.php diff -u phpdoc/scripts/html_syntax.php:1.11 phpdoc/scripts/html_syntax.php:1.12 --- phpdoc/scripts/html_syntax.php:1.11 Sat Feb 3 19:42:43 2007 +++ phpdoc/scripts/html_syntax.php Sat Feb 3 22:57:46 2007 @@ -39,8 +39,11 @@ } } +function callback_highlight_xml_indent($match) { + return strtr($match[0], array(' ' => ' ', "\t" => ' ')); +} function callback_highlight_xml($matches) { - $source = htmlentities($matches[1]); + $source = trim(htmlentities($matches[1])); $match = array( '/(\w+)=("|"|\')(.*?)("|"|\')/', @@ -58,13 +61,15 @@ '<span class="tags">!DOCTYPE</span> <span class="attributes">$1 $2 $3$4$3</span>', '<<span class="tags">$1</span>', '</<span class="tags">$1</span>>', - '<span class="comment"><!--', + '<span class="comment"><!--', '--></span>', '<<span class="tags">?xml</span> $1 <span class="tags">?</span>>', '<span class="tags"><![<span class="keyword">CDATA</span>[</span><span class="cdata">$1</span><span class="tags">]]></span>' ); - - return '<div class="xmlcode">' . nl2br(preg_replace($match, $replace, $source)) . '</div>'; + + $result = preg_replace($match, $replace, $source); + $result = preg_replace_callback('/^([ \t]+)/m', 'callback_highlight_xml_indent', $result); + return '<div class="xmlcode">' . nl2br($result) . '</div>'; } $files = $_SERVER["argv"];