/** * */ public function testBr() { $this->assertSame('<br>', Tag::br()); }
/** * Wraps a string in paragraphs. Wraps double line breaks with <p> and </p>, * and replaces single line breaks with <br>. * * @param string $string The string to convert to paragraphs * * @return string * * @todo Correctly handle blank lines with horizontal whitespace! */ public static function nl2p($string) { $string = '<p>' . trim($string) . '</p>'; $string = preg_replace("/(?<![\n\r])(?:\r|\n|\r\n)(?![\n\r])/", Tag::br(), $string); $string = preg_replace("/(?<![\n\r])[\n\r]{2,}(?![\n\r])/", "</p>\n<p>", $string); return $string; }