Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function traverseDOM(start){
- var cc = function(){return scanNode(start, stop);};
- function stop(){
- cc = stop;
- throw StopIteration;
- }
- function yield(value, c){
- cc = c;
- return value;
- }
- function scanNode(node, c){
- if (node.nextSibling)
- var nextc = function(){return scanNode(node.nextSibling, c);};
- else
- var nextc = c;
- if (/* node is proper span element */)
- return yield(node.firstChild.nodeValue, nextc);
- else if (/* node is proper br element */)
- return yield("\n", nextc);
- else
- /* flatten node, yield its textual content */;
- }
- return {next: function(){return cc();}};
- }
Advertisement
Add Comment
Please, Sign In to add comment