summaryrefslogtreecommitdiffstats
path: root/system/libraries/Typography.php
diff options
context:
space:
mode:
authorDerek Jones <derek.jones@ellislab.com>2008-12-11 18:55:42 +0100
committerDerek Jones <derek.jones@ellislab.com>2008-12-11 18:55:42 +0100
commit4777fb822d25d91f236298360a406cfbb0f38091 (patch)
tree6d2586021a34a2b3eab0aacae65a7e63fc19db5f /system/libraries/Typography.php
parentffa4c84a3136ece9a25a40daad1194047da8fce4 (diff)
more accurate HTML comment restoration
Diffstat (limited to 'system/libraries/Typography.php')
-rw-r--r--system/libraries/Typography.php7
1 files changed, 5 insertions, 2 deletions
diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php
index a4d1e3548..3875bd5c4 100644
--- a/system/libraries/Typography.php
+++ b/system/libraries/Typography.php
@@ -180,9 +180,12 @@ class CI_Typography {
// restore HTML comments
for ($i = 0, $total = count($html_comments); $i < $total; $i++)
{
- $str = preg_replace('#(?:<p>)?{@HC'.$i.'}(?:\s*</p>)?#s', $html_comments[$i], $str);
+ // remove surrounding paragraph tags, but only if there's an opening paragraph tag
+ // otherwise HTML comments at the ends of paragraphs will have the closing tag removed
+ // if '<p>{@HC1}' then replace <p>{@HC1}</p> with the comment, else replace only {@HC1} with the comment
+ $str = preg_replace('#(?(?=<p>\{@HC'.$i.'\})<p>\{@HC'.$i.'\}(\s*</p>)|\{@HC'.$i.'\})#s', $html_comments[$i], $str);
}
-
+
// Final clean up
$table = array(