node-htmlparser icon indicating copy to clipboard operation
node-htmlparser copied to clipboard

Convert JSON back to HTML

Open tiholic opened this issue 7 years ago • 2 comments

I would like to convert DOM to JSON, modify the JSON and convet it back to DOM String.

Please suggest

tiholic avatar Jul 25 '18 17:07 tiholic

I also need this - it looks like you can get the raw version of any node, as in https://www.npmjs.com/package/htmlparser#option-verbose

However, it's more complex than just adding back the < and > - we'd need to also recurse down into the child notes, AND add close tags </...> for each.

I wish it would just preserve the entire original HTML for each element, maybe as an original property. This would include a lot of redundant information, but really is useful for some use cases (like ours in https://github.com/publiclab/inline-markdown-editor/pull/52).

jywarren avatar Mar 05 '19 17:03 jywarren

OK, i did a very basic implementation (i think) here: #82. Can folks test it out?

jywarren avatar Mar 05 '19 17:03 jywarren