html-parse-stringify2
html-parse-stringify2 copied to clipboard
In case "plain text + tags", text is ignored
Thank you for this helpful package!
Almost the same problem as #11 still remain: Parsing a plain text node + tags results in an list without plain text. Current behavior:
const lib = require("html-parse-stringify2");
const nodes = lib.parse("Hello, <b>world!</b>");
nodes.length === 1;
Expected behavior:
const lib = require("html-parse-stringify2");
const nodes = lib.parse("Hello, <b>world!</b>")
nodes.length === 2;
nodes[0].type === "text";
nodes[0].content === "Hello, ";
nodes[0].type === "tag";
nodes[0].name === "b";
And the same workaround works:
const parse = function(htmlAndText){
return lib.parse("<top>" + htmlAndText + "</top>")[0].children;
};