So I have and advanced html string that contain some missing tags name.
When using node-html-parser
the parser are not able to parse those html in a right way and some html goes missing.
Look here in snack
I need to be able to find and add/remove those missing tags name.
There is two solution I can do
- 1- remove the start tag of the missing end tags
- 2- add the tag of the missing end tags.
So far I am not able to find a fast solution to this problem, and I am using react-native-html-parser
to parse the html first. this will close those tags and then I am using node-html-parser
to parse the html I am getting from react-native-html-parser
.
But this way is way to annoying as I am getting performance issue.
Is there a way to fix this? using some regexp
or something that is fast.
Here is my current code that are not working.
import { parse} from 'node-html-parser';var html = `<div><div id="chr-content"><span> lkjasdkjasdkljakldj</div></div>`var container = parse('<div>'+ h +'</div>');var content = container.querySelector('#chr-content');console.log( content != null ? 'found ' : 'not found ');