Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions lib/node-htmlparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,9 @@ inherits(RssHandler, DefaultHandler);
try {
entry.pubDate = new Date(DomUtils.getElementsByTagName("updated", item.children, false)[0].children[0].data);
} catch (ex) { }
try {
entry.content = DomUtils.outerHTML(DomUtils.getElementsByTagName("content", item.children, false)[0].children[0]);
} catch (ex) { }
feed.items.push(entry);
});
}
Expand Down Expand Up @@ -799,6 +802,41 @@ function DefaultHandler (callback, options) {
, getElementsByTagType: function DomUtils$getElementsByTagType (type, currentElement, recurse, limit) {
return(DomUtils.getElements({ tag_type: type }, currentElement, recurse, limit));
}

, outerHTML: function DomUtils$outerHTML(currentElement) {
var runningMarkup = '';

switch (currentElement.type) {

case 'tag':

if (currentElement.name == 'br') {
runningMarkup = runningMarkup + '<br />';
} else {
runningMarkup = runningMarkup + '<' + currentElement.name;
if (currentElement.attribs) {
for (var key in currentElement.attribs) {
runningMarkup = runningMarkup + ' ' + key + '=' + '"' + currentElement.attribs[key] + '"';
};
}
runningMarkup = runningMarkup + '>';
if (currentElement.children) {
currentElement.children.forEach(function(el) {
runningMarkup = runningMarkup + DomUtils.outerHTML(el);
});
}
runningMarkup = runningMarkup + '</' + currentElement.name + '>';
}
break;

case 'text':
runningMarkup = runningMarkup + currentElement.data;
break;

}

return runningMarkup;
}
}

function inherits (ctor, superCtor) {
Expand Down