You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello @hecrj! Thank you for the library. I am using this for a tool to convert raw HTML into code generated for https://github.com/matheus23/elm-tailwind-modules. The main use is to copy-paste examples from Tailwind docs and get valid Elm code generated.
I'm running into parser errors because the examples often use self-closing HTML tags within svg. I'm only parsing the raw nodes and then using those to generate Strings, so I don't actually need any fixes except for handling self-closing tag support for my use case (so this is not a request for any sort of svg support per se).
I would like to contribute this fix and wanted to start with a conversation before making a PR. I was able to make a change to handle self-closing tags like this:
This seems to be perfectly robust. My main question is whether you want to handle special cases to explicitly disallow self-closing tags in some cases.
The HTML spec is surprisingly strict about disallowing self-closing tags in many cases.
Then, if the element is one of the void elements, or if the element is a foreign element, then there may be a single U+002F SOLIDUS character (/). This character has no effect on void elements, but on foreign elements it marks the start tag as self-closing.
Foreign elements
Elements from the MathML namespace and the SVG namespace.
So my question is:
Would you be open to a pull request adding support for self-closing tags?
If so, what should I do about self-closing rules? Is it okay to allow self-closing tags anywhere (more permissive than the spec)? Or should some special care be taken to give a parser error when there is a self-closing tag in a context where it is disallowed by the spec?
If we go the approach of disallowing self-closing tags outside of foreign elements, then it may require more context in the parser to keep track of when it goes into an SVG element. That would mean checking for the SVG namespace
Hello @hecrj! Thank you for the library. I am using this for a tool to convert raw HTML into code generated for https://github.com/matheus23/elm-tailwind-modules. The main use is to copy-paste examples from Tailwind docs and get valid Elm code generated.
I'm running into parser errors because the examples often use self-closing HTML tags within
svg
. I'm only parsing the raw nodes and then using those to generate Strings, so I don't actually need any fixes except for handling self-closing tag support for my use case (so this is not a request for any sort of svg support per se).I would like to contribute this fix and wanted to start with a conversation before making a PR. I was able to make a change to handle self-closing tags like this:
dillonkearns@0e90d84
This seems to be perfectly robust. My main question is whether you want to handle special cases to explicitly disallow self-closing tags in some cases.
The HTML spec is surprisingly strict about disallowing self-closing tags in many cases.
And foreign elements are defined as
So my question is:
If we go the approach of disallowing self-closing tags outside of foreign elements, then it may require more context in the parser to keep track of when it goes into an SVG element. That would mean checking for the SVG namespace
Thanks again for the package! I'd love to contribute the change if you're open to it, let me know your thoughts.
The text was updated successfully, but these errors were encountered: