Exemple #1
0
 /**
  *
  */
 public function testBr()
 {
     $this->assertSame('<br>', Tag::br());
 }
Exemple #2
0
 /**
  * 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;
 }