Index: wp-includes/formatting.php
===================================================================
--- wp-includes/formatting.php	(revision 38388)
+++ wp-includes/formatting.php	(working copy)
@@ -474,6 +474,14 @@
 	// Add a double line break below block-level closing tags.
 	$pee = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $pee);
 
+	// Add a double line break above and below Shortcode opening tags.
+	global $shortcode_tags;
+	$tagregexp = join( '|', array_map( 'preg_quote', array_keys( $shortcode_tags ) ) );
+	$pee = preg_replace( '!(\[(\[?)(' . $tagregexp . ')\](\]?))!', "\n\n$1\n\n", $pee );
+
+	// Add a double line break above and below Shortcode closing tags.
+	$pee = preg_replace( '!((\[?)\[\/(' . $tagregexp . ')\](\]?))!', "\n\n$1\n\n", $pee );
+
 	// Standardize newline characters to "\n".
 	$pee = str_replace(array("\r\n", "\r"), "\n", $pee);
 
@@ -523,6 +531,10 @@
 	// Under certain strange conditions it could create a P of entirely whitespace.
 	$pee = preg_replace('|<p>\s*</p>|', '', $pee);
 
+	// Remove <p> tags and line breaks around shortcodes
+	$pee = preg_replace( '!\n<p>(\[(\[?)(' . $tagregexp . ')\](\]?))</p>\n!', "$1", $pee );
+	$pee = preg_replace( '!\n<p>((\[?)\[\/(' . $tagregexp . ')\](\]?))</p>\n!', "$1", $pee );
+
 	// Add a closing <p> inside <div>, <address>, or <form> tag if missing.
 	$pee = preg_replace('!<p>([^<]+)</(div|address|form)>!', "<p>$1</p></$2>", $pee);
 
@@ -538,7 +550,6 @@
 
 	// If an opening or closing block element tag is preceded by an opening <p> tag, remove it.
 	$pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)!', "$1", $pee);
-
 	// If an opening or closing block element tag is followed by a closing <p> tag, remove it.
 	$pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee);
 
