Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Util for htmlparser for extracting text from HTML elements and it's child nodes
- * For example for "<td>abc <a href="ff">bb</a></td>" it will return "abc bb"
- */
- extractText = function(item) {
- var result = '';
- if (item.type === 'text') {
- result += item.raw;
- }
- if (item.children) {
- item.children.forEach (function (a) {
- result += extractText (a);
- });
- }
- return result;
- }
- exports.extractText = extractText;
Add Comment
Please, Sign In to add comment