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 element in <head>
#1035
Comments
Potentially we could add such an option, but then I'd ask why you use an HTML5 conform parser if what you input is not HTML5 confirm. Maybe XML is more what you look for? Anyway - is there any chance to either use an existing (head-allowed) element or some notation such as the processing elements or comments? (I don't want to change your SSG - just want to see if there is any other option besides changing a lib that is used underneath) |
I guess I didn't realise it would do this, I have used AngleSharp in the past and had the idea of using it with this project.
At this stage I am just doing unit tests and experimenting to see what direction to go in. |
Hello, just wanted to update here. I will close he issue. Thanks |
I'm going to open this again and humbly request that an option could be added to the HTMLParserOptions so that custom elements be allowed in the My suggestion would be similar to IsStrictMode: var parser = new HtmlParser(new HtmlParserOptions
{
IsHtmlConfirm = false
});
var html = "<html><head><site-include type="partial" name="scripts"></site-include></head><body></body></html>";
var document = parser.ParseDocument(html);
Console.WriteLine(document.DocumentElement.ToHtml()); What do you think? |
Well, in general something like that would be feasible I think. I wouldn't call it I would also add this then also to other parts of the document where custom elements would right now not be allowed / shifted away. |
Yeah sorry I mis-spelt
Custom elements are allowed in the
I don't see why I (or others in the future) can't use a custom element in the |
No it would not. This option would also allow custom elements to be used, e.g., in
Hm? Maybe we are talking in different directions. AngleSharp follows the HTML5 spec. Custom elements are only allowed in certain areas (e.g., as descendant of |
So are you willing to work on this or sponsor this? @LukeTOBrien |
I don't have the time at the moment to work on this, perhaps in the future. I could sponsor it for sure. But perhaps I will
Having a HTML document that doesn't follow the spec is a use case I think, like here I am using a place-holder element and replacing it. Perhaps I will close this issue again and continue using HAP. I can always come back. |
I am really confused here. I propose to add something and then you just leave again? And having something spec violating in a parser that has "spec compliant" as one of the core values is ... well - but we add things where it makes sense. Again, I am not sure what your problem is with my proposal? All I did was to give it a more accurate name and to expand it from "like now + 1 more position" to "all positions". |
I didn't mean to sound ungrateful, sorry, I do like your proposal but I just don't have time to work on this right now. |
I just found this when looking for a library to read HTML and while I have not reached as far as custom elements I have a similar problem with custom attributes. And seeing this I can see that custom elements in the head could come. Its for a template solution so some custom markup will be present and while a previous solution used only data-attributes, it was a bit cumbersome, custom attributes within tables or head for that matter would help make the usage of the templates much easier, so is this still something that might come? |
Any attribute is valid as long as its name is following the right syntax. For attributes there are no such checks.
As mentioned we can have the option to produce an invalid DOM / allow custom/any elements in the head (or actually anywhere). Open here either for sponsorship or community contributions. |
Hello, I just did the sponsorship thing. I was wondering perhaps you could add a
A
|
Great - what did you do? Because usually I get a GitHub notification or at least something is shown on GitHub. I don't see anything; but maybe you did something else or sponsored somebody else?
Well, since this would pretty much hide what is actually going on I'd still go with |
Yes it seems something went wrong because it seems you still have 6 sponsor and I don't appear. |
I just did it again using my personal account, and this time I received an email saying there was a problem with billing. |
3rd time lucky ;) |
Yeah that worked - thanks, much appreciated! |
Landed in Just remember that children of the custom element still follow the rules of the outer context, e.g., in head only certain elements may be placed. That does not make a difference in case of of a directly closed / empty element is in the OP. |
That's great, thanks!
I must get around to trying this at some point.
…On Tue, May 31, 2022 at 2:36 PM Florian Rappl ***@***.***> wrote:
Closed #1035 <#1035> as
completed.
—
Reply to this email directly, view it on GitHub
<#1035 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AD3KMFO3WMQEPCYWQIRKPWLVMYIUDANCNFSM5MPW3U6A>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I came upon this today, I am developing a Static Website Generator and I want to allow for layout templates like:
So here you see the tag
site-include
denotes where a partial page should be included (in this case the scripts partial page in the head).In my C# code I then
QuerySelector
thesite-include
andReplaceWith
the partial.But or course the problem is that when I use the
HTMLParser
the above template gets turne into:Is there any option I can set to the
HTMLParser
to allow custom elements inside the<head>
?I believe your parser is working as is correct for browsers, but it is not what I need for my purposes.
The text was updated successfully, but these errors were encountered: