cvs: phpdoc /scripts html_syntax.php

From: Date: Sat, 03 Feb 2007 22:57:46 +0000
Subject: cvs: phpdoc /scripts html_syntax.php
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969375221@lists.php.net to get a copy of this message
colder Sat Feb 3 22:57:46 2007 UTC Modified files: /phpdoc/scripts html_syntax.php Log: -Indent the XML tree with &nbsp;'s - < needs to be &lt; 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(' ' => '&nbsp;', "\t" => '&nbsp;&nbsp;&nbsp;&nbsp;')); +} function callback_highlight_xml($matches) { - $source = htmlentities($matches[1]); + $source = trim(htmlentities($matches[1])); $match = array( '/(\w+)=(&quot;|"|\')(.*?)(&quot;|"|\')/', @@ -58,13 +61,15 @@ '<span class="tags">!DOCTYPE</span> <span class="attributes">$1 $2 $3$4$3</span>', '&lt;<span class="tags">$1</span>', '&lt;/<span class="tags">$1</span>&gt;', - '<span class="comment"><!--', + '<span class="comment">&lt;!--', '--&gt;</span>', '&lt;<span class="tags">?xml</span> $1 <span class="tags">?</span>&gt;', '<span class="tags">&lt;![<span class="keyword">CDATA</span>[</span><span class="cdata">$1</span><span class="tags">]]&gt;</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"];

« previous php.doc (#969375221) next »