Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In case "plain text + tags", text is ignored #25

Open
maxsimych opened this issue Aug 26, 2020 · 0 comments
Open

In case "plain text + tags", text is ignored #25

maxsimych opened this issue Aug 26, 2020 · 0 comments

Comments

@maxsimych
Copy link

maxsimych commented Aug 26, 2020

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;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant