Skip to content

htmlToText/convert functions much slower than fromString #265

Closed
@oanacapatana

Description

@oanacapatana

Updating from 5.1.1 to 9.0.0 makes the html to text conversion 4 times slower.
In 5.1.1 was using fromString function which is now deprecated.
In 9.0.0 have tried with both convert and htmlToText functions and they are both 4 times slower than previous fromString method.

The method call from code is:
data = htmlToText.fromString(data, {
wordwrap: false,
noLinkBrackets: true,
preserveNewlines: true,
unorderedListItemPrefix: "*",
format: {
anchor: function (elem, fn, options) {
var h = fn(elem.children, options);
return "[" + h + "](" + elem.attribs.href + ")";
},
unorderedList: function (elem, fn, options) {
return formatUnorderedList(elem, fn, options, false);
},
text: function (elem, options) {
if (elem.next && elem.data) {
//Return the element that has an email, and add a special string to avoid removing the < >
return elem.next.name && elem.next.name.indexOf("@") !== -1 ?
elem.data + " <" + elem.next.name + DNR + ">" :
elem.data;
} else {
return elem.data;

                }
            }
        }
    });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions