diff --git a/packages/html-to-text/src/text-formatters.js b/packages/html-to-text/src/text-formatters.js index 5b9dc96..2802fbb 100644 --- a/packages/html-to-text/src/text-formatters.js +++ b/packages/html-to-text/src/text-formatters.js @@ -231,7 +231,7 @@ function formatList (elem, walk, builder, formatOptions, nextPrefixCallback) { * @type { FormatCallback } */ function formatUnorderedList (elem, walk, builder, formatOptions) { - const prefix = formatOptions.itemPrefix || ' * '; + const prefix = (typeof formatOptions.itemPrefix === 'string') ? formatOptions.itemPrefix : ' * '; return formatList(elem, walk, builder, formatOptions, () => prefix); } diff --git a/packages/html-to-text/test/tags.js b/packages/html-to-text/test/tags.js index b2e042f..e761e7b 100644 --- a/packages/html-to-text/test/tags.js +++ b/packages/html-to-text/test/tags.js @@ -427,6 +427,17 @@ describe('tags', function () { expect(htmlToText(html, options)).to.equal(expected); }); + it('should handle an unordered list with an empty prefix option', function () { + const html = ''; + const options = { + selectors: [ + { selector: 'ul', options: { itemPrefix: '' } } + ] + }; + const expected = 'foo\nbar'; + expect(htmlToText(html, options)).to.equal(expected); + }); + it('should handle nested ul correctly', function () { const html = /*html*/``; const expected = ' * foo\n * bar\n * baz.1\n * baz.2';