doc/assets/sh_main.js
function sh_extractTagsFromNodeList(nodeList, result) {
  var length = nodeList.length;
  for (var i = 0; i < length; i++) {
    var node = nodeList.item(i);
    switch (node.nodeType) {
    case 1:
      if (node.nodeName.toLowerCase() === 'br') {
        var terminator;
        if (/MSIE/.test(navigator.userAgent)) {
          terminator = '\r';
        }
        else {
          terminator = '\n';
        }
        result.text.push(terminator);
        result.pos++;
      }
      else {
        result.tags.push({node: node.cloneNode(false), pos: result.pos});
        sh_extractTagsFromNodeList(node.childNodes, result);
        result.tags.push({pos: result.pos});
      }
      break;
    case 3:
    case 4:
      result.text.push(node.data);
      result.pos += node.length;
      break;
    }
  }
}
function sh_extractTagsFromNodeList(nodeList, result) {
  var length = nodeList.length;
  for (var i = 0; i < length; i++) {
    var node = nodeList.item(i);
    switch (node.nodeType) {
    case 1:
      if (node.nodeName.toLowerCase() === 'br') {
        var terminator;
        if (/MSIE/.test(navigator.userAgent)) {
          terminator = '\r';
        }
        else {
          terminator = '\n';
        }
        result.text.push(terminator);
        result.pos++;
      }
      else {
        result.tags.push({node: node.cloneNode(false), pos: result.pos});
        sh_extractTagsFromNodeList(node.childNodes, result);
        result.tags.push({pos: result.pos});
      }
      break;
    case 3:
    case 4:
      result.text.push(node.data);
      result.pos += node.length;
      break;
    }
  }
}
function sh_extractTagsFromNodeList ( nodeList , result ) { var length = nodeList . length ; for ( var i = 0 ; i < length ; i ++ ) { var node = nodeList . item ( i ) ; switch ( node . nodeType ) { case 1 : if ( node . nodeName . toLowerCase ( ) === 'br' ) { var terminator ; if ( / MSIE / . test ( navigator . userAgent ) ) { terminator = '\r' ; } else { terminator = '\n' ; } result . text . push ( terminator ) ; result . pos ++ ; } else { result . tags . push ( { node : node . cloneNode ( false ) , pos : result . pos } ) ; sh_extractTagsFromNodeList ( node . childNodes , result ) ; result . tags . push ( { pos : result . pos } ) ; } break ; case 3 : case 4 : result . text . push ( node . data ) ; result . pos += node . length ; break ; } } }
Extracts the tags from an HTML DOM NodeList.
@param  nodeList  a DOM NodeList
@param  result  an object with text, tags and pos properties
Extracts the tags from an HTML DOM NodeList .