Index: src/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js
===================================================================
--- src/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js	(revision 36733)
+++ src/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js	(working copy)
@@ -26,7 +26,8 @@
 			{ start: '#####', format: 'h5' },
 			{ start: '######', format: 'h6' },
 			{ start: '>', format: 'blockquote' },
-			{ regExp: /^\s*(?:(?:\* ?){3,}|(?:_ ?){3,}|(?:- ?){3,})\s*$/, element: 'hr' }
+			{ regExp: /^\s*(?:(?:\* ?){3,}|(?:_ ?){3,}|(?:- ?){3,})\s*$/, element: 'hr' },
+			{ regExp: /^`{3,}$/, format: 'pre' }
 		];
 
 		var inlinePatterns = [
@@ -60,7 +61,7 @@
 			}
 
 			if ( event.keyCode === VK.ENTER && ! VK.modifierPressed( event ) ) {
-				enter();
+				enter( event );
 			}
 		}, true );
 
@@ -230,12 +231,13 @@
 			} );
 		}
 
-		function enter() {
+		function enter( event ) {
 			var rng = editor.selection.getRng(),
 				start = rng.startContainer,
+				offset = rng.startOffset,
 				node = firstTextNode( start ),
 				i = enterPatterns.length,
-				text, pattern, parent;
+				text, pattern, parent, match;
 
 			if ( ! node ) {
 				return;
@@ -250,7 +252,7 @@
 						break;
 					}
 				} else if ( enterPatterns[ i ].regExp ) {
-					if ( enterPatterns[ i ].regExp.test( text ) ) {
+					if ( match = text.match( enterPatterns[ i ].regExp ) ) {
 						pattern = enterPatterns[ i ];
 						break;
 					}
@@ -265,27 +267,56 @@
 				return;
 			}
 
-			editor.once( 'keyup', function() {
+			if ( match && pattern.format ) {
 				editor.undoManager.add();
 
 				editor.undoManager.transact( function() {
-					if ( pattern.format ) {
-						editor.formatter.apply( pattern.format, {}, node );
-						node.replaceData( 0, node.data.length, ltrim( node.data.slice( pattern.start.length ) ) );
-					} else if ( pattern.element ) {
-						parent = node.parentNode && node.parentNode.parentNode;
+					editor.formatter.apply( pattern.format );
 
-						if ( parent ) {
-							parent.replaceChild( document.createElement( pattern.element ), node.parentNode );
-						}
+					parent = node.parentNode;
+
+					node.deleteData( 0, match[0].length );
+
+					if ( ! parent.innerHTML ) {
+						parent.appendChild( document.createElement( 'br' ) );
 					}
+
+					editor.selection.setCursorLocation( parent );
 				} );
 
 				// We need to wait for native events to be triggered.
 				setTimeout( function() {
 					canUndo = 'enter';
 				} );
-			} );
+
+				event.preventDefault();
+				event.stopImmediatePropagation();
+			} else {
+				editor.once( 'keyup', function() {
+					editor.undoManager.add();
+
+					editor.undoManager.transact( function() {
+						if ( pattern.format ) {
+							editor.formatter.apply( pattern.format, {}, node );
+
+							if ( pattern.start ) {
+								node.replaceData( 0, node.data.length, ltrim( node.data.slice( pattern.start.length ) ) );
+							}
+						} else if ( pattern.element ) {
+							parent = node.parentNode && node.parentNode.parentNode;
+
+							if ( parent ) {
+								parent.replaceChild( document.createElement( pattern.element ), node.parentNode );
+							}
+						}
+					} );
+
+					// We need to wait for native events to be triggered.
+					setTimeout( function() {
+						canUndo = 'enter';
+					} );
+				} );
+			}
 		}
 
 		function ltrim( text ) {
Index: tests/qunit/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js
===================================================================
--- tests/qunit/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js	(revision 36733)
+++ tests/qunit/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js	(working copy)
@@ -311,9 +311,24 @@
 		}, assert.async() );
 	} );
 
-	QUnit.test( 'Horizontal Rule', function( assert ) {
+	QUnit.test( 'Horizontal Rule.', function( assert ) {
 		type( '   ---   \n', function() {
 			assert.equal( editor.getContent(), '<hr />\n<p>&nbsp;</p>' );
 		}, assert.async() );
 	} );
+
+	QUnit.test( 'Code block.', function( assert ) {
+		type( '```\ntest', function() {
+			assert.equal( editor.getContent(), '<pre>test</pre>' );
+		}, assert.async() );
+	} );
+
+	QUnit.test( 'Code block with text.', function( assert ) {
+		editor.setContent( '<p>test</p>' );
+		editor.selection.setCursorLocation();
+
+		type( '```\n', function() {
+			assert.equal( editor.getContent(), '<pre>test</pre>' );
+		}, assert.async() );
+	} );
 } )( window.jQuery, window.QUnit, window.tinymce, window.setTimeout );
