summaryrefslogtreecommitdiffstats
path: root/system/libraries/Typography.php
diff options
context:
space:
mode:
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(