cvs: pear /PHPDoc/renderer/html PhpdocHTMLRenderer.php

From: Date: Thu, 20 Dec 2001 11:04:08 +0000
Subject: cvs: pear /PHPDoc/renderer/html PhpdocHTMLRenderer.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-1629@lists.php.net to get a copy of this message
hayk Thu Dec 20 06:04:08 2001 EDT Modified files: /pear/PHPDoc/renderer/html PhpdocHTMLRenderer.php Log: * Now double linebreaks won't be replaced with '<p>' in a pre-formatted text (<pre>...</pre>). Index: pear/PHPDoc/renderer/html/PhpdocHTMLRenderer.php diff -u pear/PHPDoc/renderer/html/PhpdocHTMLRenderer.php:1.2 pear/PHPDoc/renderer/html/PhpdocHTMLRenderer.php:1.3 --- pear/PHPDoc/renderer/html/PhpdocHTMLRenderer.php:1.2 Thu Aug 23 15:39:28 2001 +++ pear/PHPDoc/renderer/html/PhpdocHTMLRenderer.php Thu Dec 20 06:04:08 2001 @@ -2,7 +2,7 @@ /** * Default HTML Renderer based on templates. * -* @version $Id: PhpdocHTMLRenderer.php,v 1.2 2001/08/23 19:39:28 chagenbu Exp $ +* @version $Id: PhpdocHTMLRenderer.php,v 1.3 2001/12/20 11:04:08 hayk Exp $ */ class PhpdocHTMLRenderer extends PhpdocRendererObject { @@ -38,7 +38,7 @@ /** * Sets a directory path prefix. * - * @param string + * @param string $path */ function setPath($path) { @@ -51,7 +51,7 @@ /** * Sets the template directory. * - * @param string + * @param string $templateRoot */ function setTemplateRoot($templateRoot) { @@ -69,11 +69,23 @@ * customize your rendering result. * strip some tags. * - * @param string String to encode - * @return string $string Encoded string + * @param string $string String to encode + * @return string Encoded string */ function encode($string) { - return str_replace(PHPDOC_LINEBREAK . PHPDOC_LINEBREAK, '<p>', strip_tags($string, '<a>,<i>,<b>,<pre>')); + $string = strip_tags ($string, PHPDOC_ALLOWEDHTMLTAGS); + + if ($regs = preg_split ("/(<pre>|<\/pre>)/", $string, -1, PREG_SPLIT_DELIM_CAPTURE)) { + for ($i = 0; $i < sizeof ($regs); $i++) + { + if (($regs[$i] == "<pre>") && ($regs[$i+2] == "</pre>")) $i += 2; + else $regs[$i] = preg_replace ("/(" . PHPDOC_LINEBREAK . PHPDOC_LINEBREAK . ")/", '<p>', $regs[$i]); + } + return implode ("", $regs); + } else { + return preg_replace ("/(" . PHPDOC_LINEBREAK . PHPDOC_LINEBREAK . ")/", '<p>', $string); + } + } // end func encode } // end class PhpdocHTMLRenderer

« previous php.pear.cvs (#1629) next »