-
-
Notifications
You must be signed in to change notification settings - Fork 126
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
Is it compatible with htmlparser format? #47
Comments
@oliverodaa Should be possible: $ node
> const domToReact = require('html-react-parser/lib/dom-to-react');
> const htmlparserDoc = [{ type: 'tag', name: 'a', attribs: { href: 'test.html' }, children: [{ data: 'hello world', type: 'text' }] }];
> domToReact(htmlparserDoc);
{ '$$typeof': Symbol(react.element),
type: 'a',
key: null,
ref: null,
props: { href: 'test.html', children: 'hello world' },
_owner: null,
_store: {} } Let me know if you experience any issues; otherwise, please close the issue if it works. |
Thank you for the quick response! I am still in the process of working on it but will be sure to close the issue when I have confirmed that it either works or doesn't work. |
I can confirm that it does in fact work! I ended up using For anyone stumbling upon this, here is the code I used to strip those circular references: JSON.stringify(obj,
function(key, value) {
return key === 'parent' || key === 'next' || key === 'prev'
? undefined
: value;
}); |
Is it possible for us to call the following?
The
htmlparser2
format contains circular references, which prevents us from callingJSON.stringify()
on it, so we'd like to usehtmlparser
if we can.The text was updated successfully, but these errors were encountered: