Guest User

Untitled

a guest
Jan 23rd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. /**
  2. * Util for htmlparser for extracting text from HTML elements and it's child nodes
  3. * For example for "<td>abc <a href="ff">bb</a></td>" it will return "abc bb"
  4. */
  5. extractText = function(item) {
  6. var result = '';
  7.  
  8. if (item.type === 'text') {
  9. result += item.raw;
  10. }
  11.  
  12. if (item.children) {
  13. item.children.forEach (function (a) {
  14. result += extractText (a);
  15. });
  16. }
  17.  
  18. return result;
  19. }
  20.  
  21. exports.extractText = extractText;
Add Comment
Please, Sign In to add comment