-
-
Notifications
You must be signed in to change notification settings - Fork 132
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
Don't change case of tags #62
Comments
Can I ask for an example of this problem? Technically, shouldn't HTML tags and attributes be case-insensitive?
Actually, the attributes are lowercased when the HTML string is transformed to DOM nodes. This is coming from html-dom-parser, which uses htmlparser2 under the hood (when using with Node.js). I'm open to making these options configurable. |
Sorry for revive this issue, but I'm using this package and I need the tags to be camel case, because C# will parse it later (I know, it's messy, not my code and I cant change it)... I've read the |
@thismarcoantonio There's a PR (#79) that might do what you need |
To give you an update @thismarcoantonio, it turns out that #79 ended up not getting merged. Regarding your question about the tags being camelCase, are you referring to the raw HTML markup that gets passed to the parser? |
Yes, those tags are like: |
Another problem related to this: Parsing a string containing onclick or viewbox attributes, those attributes are invalid in React because React uses onClick and viewBox instead, so in converting the attributes from an html string to React components they need to be transformed to camel case or they break. It would be nice if these conversions could just happen by default, but alternatively if you could provide an option for replacing attributes that would work. |
@remarkablemark Any updates regarding this issue? |
I'm facing a similar issue but in my case, my string to be parsed is like Basically, I need help in parsing the string which has custom components. |
i Am working on that issue i am coding at present a clean fork of htmlparser2 and parse5 joing both algorythms you will then be able to use parse5's react dom adapter that will be based on this code base |
In $ node
> const parse = require('html-react-parser');
> parse('<FooBar>baz</FooBar>', { htmlparser2: { lowerCaseTags: false } });
{
'$$typeof': Symbol(react.element),
type: 'FooBar',
key: null,
ref: null,
props: { children: 'baz' },
_owner: null,
_store: {}
} See README.md, Repl.it demo, or pull request #161 for more information. |
docs(readme): update FAQ with how to preserve case of tags (#62)
I also updated the README FAQ |
I'm having this same problem. But I need it client-side. Any news on it? |
@BaniGrisson Unfortunately there is no update on adding the support in html-dom-parser. |
Is it possible to use a React component with this lib? |
@linonetwo do you mean the input being JSX instead of HTML? If so, this library doesn't support that. There should be other libraries that can do that |
@remarkablemark You can use |
Also, maybe this will help to eliminate the confusion around options that work only in NodeJS environment, but not in the browser. |
Copied the comments to a more recent thread. |
I noticed that the parser changes everything to lower case, which is bad for me since I have some case sensitive tags.
Is there a way to prevent this?
The text was updated successfully, but these errors were encountered: