Skip to content

Commit 4c0962e

Browse files
committed
https://github.com/werk85/node-html-to-text/issues/11
1 parent c1de73e commit 4c0962e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/formatter.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ function formatHeading(elem, fn, options) {
2222
}
2323

2424
function formatAnchor(elem, fn, options) {
25-
return elem.attribs.href.replace(/^mailto\:/, '');
25+
if (elem.attribs && elem.attribs.href) {
26+
return elem.attribs.href.replace(/^mailto\:/, '');
27+
}
28+
else {
29+
return helper.wordwrap(helper.decodeHTMLEntities(_s.strip(elem.raw)), options.wordwrap);
30+
}
2631
};
2732

2833
function formatHorizontalLine(elem, fn, options) {
@@ -135,4 +140,4 @@ exports.table = formatTable;
135140
exports.orderedList = formatOrderedList;
136141
exports.unorderedList = formatUnorderedList;
137142
exports.listItem = formatListItem;
138-
exports.horizontalLine = formatHorizontalLine;
143+
exports.horizontalLine = formatHorizontalLine;

0 commit comments

Comments
 (0)