function replaceRange(range, html) {
  var documentFragment, newElement;

  range.deleteContents();

  // Create a DocumentFragment to insert and populate it with HTML
  documentFragment = range.createContextualFragment(html);

  documentFragment = Utils.sanitizeDocumentFragment(documentFragment);

  // After inserting the node contents, the node is empty. So we need to save a
  // reference to the element that we need to return.
  newElement = documentFragment.firstChild;

  range.insertNode(documentFragment);

  // In some clients (and maybe some versions of those clients), on some pages,
  // the newly inserted rendered Markdown will be selected. It looks better and
  // is slightly less annoying if the text is not selected, and consistency
  // across platforms is good. So we're going to collapse the selection.
  // Note that specifying the `toStart` argument to `true` seems to be necessary
  // in order to actually get a cursor in the editor.
  // Fixes #427: https://github.com/adam-p/markdown-here/issues/427
  range.collapse(true);

  return newElement;
}
Replaces the contents of `range` with the HTML string in `html`.
Returns the element that is created from `html`.
@param {Range} range
@param {string} html
@returns {Element}