code: function makeTabExpander(tabWidth) {
      var SPACES = '                ';
      var charInLine = 0;
  
      return function (plainText) {
        // walk over each character looking for tabs and newlines.
        // On tabs, expand them.  On newlines, reset charInLine.
        // Otherwise increment charInLine
        var out = null;
        var pos = 0;
        for (var i = 0, n = plainText.length; i < n; ++i) {
          var ch = plainText.charAt(i);
  
          switch (ch) {
            case '\t':
              if (!out) { out = []; }
              out.push(plainText.substring(pos, i));
              // calculate how much space we need in front of this part
              // nSpaces is the amount of padding -- the number of spaces needed
              // to move us to the next column, where columns occur at factors of
              // tabWidth.
              var nSpaces = tabWidth - (charInLine % tabWidth);
              charInLine += nSpaces;
              for (; nSpaces >= 0; nSpaces -= SPACES.length) {
                out.push(SPACES.substring(0, nSpaces));
              }
              pos = i + 1;
              break;
            case '\n':
              charInLine = 0;
              break;
            default:
              ++charInLine;
          }
        }
        if (!out) { return plainText; }
        out.push(plainText.substring(pos));
        return out.join('');
      };
    }
docs: returns a function that expand tabs to spaces.  This function can be fed
  successive chunks of text, and will maintain its own internal state to
  keep track of how tabs are expanded.
  @return {function (string) : string} a function that takes
  plain text and return the text with tabs expanded.
  @private