From 4777fb822d25d91f236298360a406cfbb0f38091 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Thu, 11 Dec 2008 17:55:42 +0000 Subject: more accurate HTML comment restoration --- system/libraries/Typography.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'system') 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('#(?:

)?{@HC'.$i.'}(?:\s*

)?#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 '

{@HC1}' then replace

{@HC1}

with the comment, else replace only {@HC1} with the comment + $str = preg_replace('#(?(?=

\{@HC'.$i.'\})

\{@HC'.$i.'\}(\s*

)|\{@HC'.$i.'\})#s', $html_comments[$i], $str); } - + // Final clean up $table = array( -- cgit v1.2.3-24-g4f1b