SelfClosing Tags have incorrect html, generated unclosed tags.
See original GitHub issueBug Report
Prerequisites
- [/] Can you reproduce the problem in a MWE?
- [/] Are you running the latest version of AngleSharp?
- [/] Did you check the FAQs to see if that helps you?
- [/] Are you reporting to the correct repository? (there are multiple AngleSharp libraries, e.g.,
AngleSharp.Css
for CSS support) - [/] Did you perform a search in the issues?
For more information, see the CONTRIBUTING
guide.
Description
Given a self-closing tag such as <input type='text' />
, doing a ToHtml()
on it, or using the OuterHtml
property both return an unclosed tag.
Steps to Reproduce
var config = Configuration.Default;
var context= BrowsingContext.New(config);
var source = "<input type='text' />";
var document = await context.OpenAsync(req => req.Content(source));
var input = document.QuerySelector("input");
input.OuterHtml.Dump();
input.ToHtml().Dump();
Expected behavior: returns <input type='text' />
Actual behavior: returns <input type='text'>
Environment details: Windows, .NET 6.0.14
Possible Solution
I believe the above line needs to have a code path that adds />
when selfClosing
is true.
Issue Analytics
- State:
- Created 6 months ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Self-closing tag syntax error in HTML documents
Using the W3c.org HTML validator, today I started receiving a new error indicating an issue with all self-closing HTML tags. The error is:....
Read more >Escaping input with unclosed, invalid tags returns it ...
To Reproduce From the Node REPL: > const s = require('sanitize-html') undefined > s("here's a string with a tag.
Read more >The case against self-closing tags in HTML
A major part of the problem is that /> is sometimes ignored, and sometimes not, within the same HTML document. Could we have...
Read more >What are Self Closing Tags in HTML?
Self -closing tags in HTML are sometimes also known as empty tags, void tags, singletons tags, etc. This means that these tags have...
Read more >The case against self-closing tags in HTML
Self -closing tags are an inconsequential issue. Of actual practical consequence are optional html5 tags [0]. They allow you to write html by ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We also have an XHTML formatter - so the parsed DOM could be represented in XHTML (here, we place the solidus; see https://github.com/AngleSharp/AngleSharp/blob/devel/src/AngleSharp/Xhtml/XhtmlMarkupFormatter.cs#L103).
Learn something new every day. For anyone’s future reference, this came out of a project where we are manipulating XHTML. Apparently I misunderstood the relationship between the various specs.