code: function normalizeSpaces(text)
  {
      // IE has already done this conversion, so doing it again will remove multiple nbsp
      if (browserVersion.isIE)
      {
          return text;
      }
  
      // Replace multiple spaces with a single space
      // TODO - this shouldn't occur inside PRE elements
      text = text.replace(/\ +/g, " ");
  
      // Replace &nbsp; with a space
      var nbspPattern = new RegExp(String.fromCharCode(160), "g");
      if (browserVersion.isSafari) {
  	return replaceAll(text, String.fromCharCode(160), " ");
      } else {
  	return text.replace(nbspPattern, " ");
      }
  }
docs: Replace multiple sequential spaces with a single space, and then convert &nbsp; to space.