added check that content is surrounded by a valid block level element, and if not, wrapped in paragraph tags
diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php
index 6b18a2d..94c9de0 100644
--- a/system/libraries/Typography.php
+++ b/system/libraries/Typography.php
@@ -143,6 +143,12 @@
$str .= $this->_format_newlines($chunk);
}
+ // is the whole of the content inside a block level element?
+ if ( ! preg_match("/^<(?:".$this->block_elements.")/i", $str, $match))
+ {
+ $str = "<p>{$str}</p>";
+ }
+
// Convert quotes, elipsis, and em-dashes
$str = $this->format_characters($str);