diff --git a/lib/formatter.js b/lib/formatter.js index 17bf449..7557f78 100644 --- a/lib/formatter.js +++ b/lib/formatter.js @@ -22,7 +22,11 @@ function formatHeading(elem, fn, options) { } function formatAnchor(elem, fn, options) { - return elem.attribs.href.replace(/^mailto\:/, ''); + var href = ''; + if (elem.attribs.href) { + href += elem.attribs.href.replace(/^mailto\:/, ''); + } + return href + fn(elem.children, options); }; function formatHorizontalLine(elem, fn, options) { @@ -135,4 +139,4 @@ exports.table = formatTable; exports.orderedList = formatOrderedList; exports.unorderedList = formatUnorderedList; exports.listItem = formatListItem; -exports.horizontalLine = formatHorizontalLine; \ No newline at end of file +exports.horizontalLine = formatHorizontalLine; diff --git a/lib/html-to-text.js b/lib/html-to-text.js index f8329de..2b834e1 100644 --- a/lib/html-to-text.js +++ b/lib/html-to-text.js @@ -70,7 +70,7 @@ function walk(dom, options) { _.each(dom, function(elem) { switch(elem.type) { case 'tag': - switch(elem.name) { + switch(elem.name.toLowerCase()) { case 'a': result += format.anchor(elem, walk, options); break; @@ -127,4 +127,4 @@ exports.fromFile = function(file, options, callback) { exports.fromString = function(str, options) { return htmlToText(str, options || {}); -}; \ No newline at end of file +};