Skip to content

Commit 3540426

Browse files
author
Malte Legenhausen
committed
Merge branch 'master' of github.com:werk85/node-html-to-text
2 parents d561095 + 655a754 commit 3540426

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

lib/formatter.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,10 @@ function formatTable(elem, fn, options) {
250250
}
251251
}
252252

253+
function formatBlockquote(elem, fn, options) {
254+
return '> ' + fn(elem.children, options) + '\n';
255+
}
256+
253257
exports.text = formatText;
254258
exports.image = formatImage;
255259
exports.lineBreak = formatLineBreak;
@@ -261,3 +265,4 @@ exports.orderedList = formatOrderedList;
261265
exports.unorderedList = formatUnorderedList;
262266
exports.listItem = formatListItem;
263267
exports.horizontalLine = formatHorizontalLine;
268+
exports.blockquote = formatBlockquote;

lib/html-to-text.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ function walk(dom, options, result) {
160160
? result + format.table(elem, walk, options)
161161
: walk(elem.children || [], options, result);
162162
break;
163+
case 'blockquote':
164+
result += format.blockquote(elem, walk, options)
165+
break;
163166
default:
164167
result = walk(elem.children || [], options, result);
165168
}

test/html-to-text.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,5 +601,14 @@ describe('html-to-text', function() {
601601
testString += "</body></html>";
602602
expect(htmlToText.fromString(testString)).to.equal(expectedResult);
603603
});
604+
});
605+
606+
describe('blockquote', function() {
607+
it('should handle format blockquote', function() {
608+
var testString = 'foo<blockquote>test</blockquote>bar';
609+
var expectedResult = 'foo> test\nbar';
610+
expect(htmlToText.fromString(testString)).to.equal(expectedResult);
611+
})
604612
})
613+
605614
});

0 commit comments

Comments
 (0)