diff options
author | Rick Ellis <rick.ellis@ellislab.com> | 2008-09-12 09:22:21 +0200 |
---|---|---|
committer | Rick Ellis <rick.ellis@ellislab.com> | 2008-09-12 09:22:21 +0200 |
commit | 9907df45d0003dee39480f4ea66004b2922b69c7 (patch) | |
tree | a3ff8a991b2e66113c83dbf11d9b11c3720d253e /system/libraries | |
parent | 08e38123f2b14b146f861c77c04073a3fc88c85d (diff) |
Continued working on typography class and docs
Diffstat (limited to 'system/libraries')
-rw-r--r-- | system/libraries/Typography.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php index b058fdab9..dd5f928d9 100644 --- a/system/libraries/Typography.php +++ b/system/libraries/Typography.php @@ -286,6 +286,40 @@ class CI_Typography { { $this->reduce_empty_lines = ($val === FALSE) ? FALSE : TRUE; } + + // ------------------------------------------------------------------------ + + /** + * Convert newlines to HTML line breaks except within PRE tags + * + * @access public + * @param string + * @return string + */ + function nl2br_except_pre($str) + { + $ex = explode("pre>",$str); + $ct = count($ex); + + $newstr = ""; + for ($i = 0; $i < $ct; $i++) + { + if (($i % 2) == 0) + { + $newstr .= nl2br($ex[$i]); + } + else + { + $newstr .= $ex[$i]; + } + + if ($ct - 1 != $i) + $newstr .= "pre>"; + } + + return $newstr; + } + } // END Typography Class |