From c206754bfe399f9cee4df92a3ea037a297dbb945 Mon Sep 17 00:00:00 2001
From: Derek Jones
Date: Fri, 1 Oct 2010 07:19:57 -0500
Subject: tweak to typography. Better aesthetic to placement of paragraph tags
---
system/libraries/Typography.php | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php
index 0f0a8b7a2..f058769ec 100644
--- a/system/libraries/Typography.php
+++ b/system/libraries/Typography.php
@@ -202,7 +202,7 @@ class CI_Typography {
// If the user submitted their own paragraph tags within the text
// we will retain them instead of using our tags.
- '/(*?]>)
/' => '$1', // *?]>)
/' => '$1', // )+#' => '
',
@@ -219,8 +219,17 @@ class CI_Typography {
'/\{@DQ\}/' => '"',
'/\{@SQ\}/' => "'",
'/\{@DD\}/' => '--',
- '/\{@NBS\}/' => ' '
+ '/\{@NBS\}/' => ' ',
+ // An unintended consequence of the _format_newlines function is that
+ // some of the newlines get truncated, resulting in tags
+ // starting immediately after tags on the same line.
+ // This forces a newline after such occurrences, which looks much nicer.
+ "/>\n/" => ">\n
",
+
+ // Similarly, there might be cases where a closing
will follow
+ // a closing
tag, so we'll correct it by adding a newline in between
+ "#
#" => "\n"
);
// Do we need to reduce empty lines?
@@ -337,7 +346,10 @@ class CI_Typography {
// Wrap the whole enchilada in enclosing paragraphs
if ($str != "\n")
{
- $str = ''.$str.'
';
+ // We trim off the right-side new line so that the closing tag
+ // will be positioned immediately following the string, matching
+ // the behavior of the opening tag
+ $str = '
'.rtrim($str).'
';
}
// Remove empty paragraphs if they are on the first line, as this
--
cgit v1.2.3-24-g4f1b