iliaa Wed Feb 9 15:31:57 2005 EDT
Modified files: /livedocs style_mapping.php livedoc_funcs.php Log: Don't handle user notes as if they were ALL php code. http://cvs.php.net/diff.php/livedocs/style_mapping.php?r1=1.23&r2=1.24&ty=u Index: livedocs/style_mapping.php diff -u livedocs/style_mapping.php:1.23 livedocs/style_mapping.php:1.24 --- livedocs/style_mapping.php:1.23 Wed Feb 9 13:56:00 2005 +++ livedocs/style_mapping.php Wed Feb 9 15:31:57 2005 @@ -18,7 +18,7 @@ // | Helper functions for formatting elements | // +----------------------------------------------------------------------+ // -// $Id: style_mapping.php,v 1.23 2005/02/09 18:56:00 iliaa Exp $ +// $Id: style_mapping.php,v 1.24 2005/02/09 20:31:57 iliaa Exp $ // almost XPATH.. ;-) $map = array( @@ -301,19 +301,13 @@ return '<a class="phpfunc" href="' . $link . '">' . $matches[1] . '</a></span>' . $matches[2]; } -function format_listing($node) +function highlight_php_code($str) { - $content = trim($node->content); - if (substr($content, 0, 5) == '<?php') { - $node->attributes['role'] = 'php'; - } - if (!isset($node->attributes['role'])) { - $node->attributes['role'] = ''; + if (is_array($str)) { + $str = $str[0]; } - switch ($node->attributes['role']) { - case 'php': - $content = str_replace( + $tmp = str_replace( array( ' ', '<font color="', // for PHP 4 @@ -330,11 +324,31 @@ "\n ", ' ' ), - highlight_string($content, true) - ); + highlight_string($str, true) + ); + + $tmp = preg_replace_callback('{([\w_]+)\s*</span>(\s*<span\s+class="keyword">\s*\()}m', 'format_listing_hyperlink_function', $tmp); + return sprintf('<div class="phpcode"%s>%s</div>', LTR, $tmp); +} + +function format_listing($node) +{ + $content = trim($node->content); + if (substr($content, 0, 5) == '<?php') { + $node->attributes['role'] = 'php'; + } + if (!isset($node->attributes['role'])) { + $node->attributes['role'] = ''; + } - $content = preg_replace_callback('{([\w_]+)\s*</span>(\s*<span\s+class="keyword">\s*\()}m', 'format_listing_hyperlink_function', $content); + switch ($node->attributes['role']) { + case 'php': + $content = highlight_php_code($content); + break; + case 'note': + $content = preg_replace_callback('!(\<(\?|\?php).+\?\>)!msU', 'highlight_php_code', $content); break; + case 'asp': case 'shell': case 'html': http://cvs.php.net/diff.php/livedocs/livedoc_funcs.php?r1=1.21&r2=1.22&ty=u Index: livedocs/livedoc_funcs.php diff -u livedocs/livedoc_funcs.php:1.21 livedocs/livedoc_funcs.php:1.22 --- livedocs/livedoc_funcs.php:1.21 Wed Feb 9 15:03:43 2005 +++ livedocs/livedoc_funcs.php Wed Feb 9 15:31:57 2005 @@ -299,7 +299,7 @@ $node = new stdClass; $node->content = $note['note']; - $node->attributes['role'] = 'php'; + $node->attributes['role'] = 'note'; $the_note = format_listing($node); // turn urls into links