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

Custom self closing tags are not detected properly. #40

Open
MohideenSheikSulaiman opened this issue May 11, 2020 · 3 comments
Open

Custom self closing tags are not detected properly. #40

MohideenSheikSulaiman opened this issue May 11, 2020 · 3 comments

Comments

@MohideenSheikSulaiman
Copy link

MohideenSheikSulaiman commented May 11, 2020

Hi,

I have an issue with HTML-Kit. When I parse an HTML content which has few self-closing custom tags, it is not detected properly.

Here is the sample code,

Screenshot 2020-05-11 at 11 24 22 AM

NSArray *images = [self.document querySelectorAll:@"MyTag"];

Pls, see the array results in below image

Screenshot 2020-05-11 at 11 24 27 AM

@iabudiab
Copy link
Owner

@MohideenSheikSulaiman hey there. The behaviour is correct, custom elements can't be self-closing. In this case the parser tries to guess the correct nesting of the custom elements, and you get the second <MyTag> inside the first one. According to the HTML spec only some specified elements can be self-closing (void elements & foreign).

Take a look here: HTML Elements Syntax. The void elements are: area, base, br, col, embed, hr, img, input, link, meta, param, source, track, wbr

You can put your html in a file and open it in any browser you like, chrome, firefox ..etc. All of them will behave the same. Here is chrome for example doing the same:
Screenshot 2020-05-12 at 00 57 23

@MohideenSheikSulaiman
Copy link
Author

MohideenSheikSulaiman commented May 12, 2020

@iabudiab Thanks for the info. We are using custom self-closing tags in the HTML to transfer the content between the devices. When we parse the HTML, we convert the custom tags to the defined HTML elements. So the above case creates a problem. Data loss happens.

It will be better if you can provide a custom tags support along with the (The void elements are: area, base, br, col, embed, hr, img, input, link, meta, param, source, track, wbr).

Is it possible to provide an option to pass the custom self-closing tags as an input to the parser.?

@MohideenSheikSulaiman MohideenSheikSulaiman changed the title Self closing tags are not detected properly. Custom self closing tags are not detected properly. May 12, 2020
@MohideenSheikSulaiman
Copy link
Author

@iabudiab

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

2 participants