src/react_widget.js
function getLineInfo(bRet,bNum,code) {
    var numCount = 0, hintCount = 0;
    var bLn = code.split(ln_re_), len = bLn.length;
    var iLastLn = -1, sLastNum = '0';
    for (var i=0; i < len; i++) {
      var item = bLn[i], hasHint = false;
      var sNew = item.replace(hint_re_, function(sMatch) {
        hasHint = true; hintCount += 1;
        var iTmp = sMatch.length;
        if (iLastLn + 1 == i) {
          iLastLn = i; sLastNum = (parseInt(sLastNum) + 1) + '';
          iTmp -= 1;
          sLastNum = sLastNum.slice(-iTmp);  // trim to same width: ~~
          if (sLastNum.length < iTmp) sLastNum = (new Array(iTmp-sLastNum.length+1)).join('0') + sLastNum;
          bRet[i] = sLastNum + '!';
        }
        else bRet[i] = (new Array(iTmp)).join(' ') + '!';
        return '';
      });
      
      if (hasHint)
        bLn[i] = sNew;
      else {
        var hasNum = false;
        var sNew2 = item.replace(num_re_, function(sMatch) {
          hasNum = true; numCount += 1;
          sLastNum = bRet[i] = sMatch.slice(0,-1);
          iLastLn = i;
          return '';
        });
        if (hasNum) bLn[i] = sNew2;
      }
    }
    
    if (!bRet.length)   // no changing
      return code;
    else {
      if (!hintCount && numCount <= 1) {  // avoid accident preceed-number
        bRet.splice(0);
        return code;    // no changing
      }
      else {
        if (numCount) bNum.push(numCount);
        return bLn.join('\n');
      }
    }
  }
function getLineInfo(bRet,bNum,code) {
    var numCount = 0, hintCount = 0;
    var bLn = code.split(ln_re_), len = bLn.length;
    var iLastLn = -1, sLastNum = '0';
    for (var i=0; i < len; i++) {
      var item = bLn[i], hasHint = false;
      var sNew = item.replace(hint_re_, function(sMatch) {
        hasHint = true; hintCount += 1;
        var iTmp = sMatch.length;
        if (iLastLn + 1 == i) {
          iLastLn = i; sLastNum = (parseInt(sLastNum) + 1) + '';
          iTmp -= 1;
          sLastNum = sLastNum.slice(-iTmp);  // trim to same width: ~~
          if (sLastNum.length < iTmp) sLastNum = (new Array(iTmp-sLastNum.length+1)).join('0') + sLastNum;
          bRet[i] = sLastNum + '!';
        }
        else bRet[i] = (new Array(iTmp)).join(' ') + '!';
        return '';
      });
      
      if (hasHint)
        bLn[i] = sNew;
      else {
        var hasNum = false;
        var sNew2 = item.replace(num_re_, function(sMatch) {
          hasNum = true; numCount += 1;
          sLastNum = bRet[i] = sMatch.slice(0,-1);
          iLastLn = i;
          return '';
        });
        if (hasNum) bLn[i] = sNew2;
      }
    }
    
    if (!bRet.length)   // no changing
      return code;
    else {
      if (!hintCount && numCount <= 1) {  // avoid accident preceed-number
        bRet.splice(0);
        return code;    // no changing
      }
      else {
        if (numCount) bNum.push(numCount);
        return bLn.join('\n');
      }
    }
  }
function getLineInfo ( bRet , bNum , code ) { var numCount = 0 , hintCount = 0 ; var bLn = code . split ( ln_re_ ) , len = bLn . length ; var iLastLn = - 1 , sLastNum = '0' ; for ( var i = 0 ; i < len ; i ++ ) { var item = bLn [ i ] , hasHint = false ; var sNew = item . replace ( hint_re_ , function ( sMatch ) { hasHint = true ; hintCount += 1 ; var iTmp = sMatch . length ; if ( iLastLn + 1 == i ) { iLastLn = i ; sLastNum = ( parseInt ( sLastNum ) + 1 ) + '' ; iTmp -= 1 ; sLastNum = sLastNum . slice ( - iTmp ) ; // trim to same width: ~~ if ( sLastNum . length < iTmp ) sLastNum = ( new Array ( iTmp - sLastNum . length + 1 ) ) . join ( '0' ) + sLastNum ; bRet [ i ] = sLastNum + '!' ; } else bRet [ i ] = ( new Array ( iTmp ) ) . join ( ' ' ) + '!' ; return '' ; } ) ; if ( hasHint ) bLn [ i ] = sNew ; else { var hasNum = false ; var sNew2 = item . replace ( num_re_ , function ( sMatch ) { hasNum = true ; numCount += 1 ; sLastNum = bRet [ i ] = sMatch . slice ( 0 , - 1 ) ; iLastLn = i ; return '' ; } ) ; if ( hasNum ) bLn [ i ] = sNew2 ; } } if ( ! bRet . length ) // no changing return code ; else { if ( ! hintCount && numCount <= 1 ) { // avoid accident preceed-number bRet . splice ( 0 ) ; return code ; // no changing } else { if ( numCount ) bNum . push ( numCount ) ; return bLn . join ( '\n' ) ; } } }
start with '~~' means highlight this line
start with ~~ means highlight this line