hr ) { return hr; } );
			}

			return html;
		}

		function getHtmlWithSelection( editorOrElement, root ) {
			var isEditor = editorOrElement instanceof CKEDITOR.editor,
				element =  isEditor ? editorOrElement.editable() : editorOrElement;

			root = isEditor ? element :
				   root instanceof CKEDITOR.dom.document ?
				   root.getBody() : root || CKEDITOR.document.getBody();

			function replaceWithBookmark( match, startOrEnd ) {
				var bookmark;
				switch( startOrEnd ) {
					case 'S' :
						bookma