-
Notifications
You must be signed in to change notification settings - Fork 103
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
Not closed tags are a problem #17
Comments
Argh... that's painful, indeed. :( Perhaps we should go back to XML parsing, then, to keep the case-sensitivity, and inject closing tags in some fashion, automatically? |
Yep, I think that's a good idea. It should just be one |
In general, it's a bad idea to try to edit HTML with a regex. It's
notoriously difficult to do. I'm wondering if maybe we pre-parse using one
of the other modes (XML or HTML) which handle this situation "more"
correctly - and as we parse through each element, rewrite the output
string, doing things like adding the closing slash for VOID elements and
custom nodes.
…On Mon, Jun 26, 2017 at 1:50 AM Tim Suchanek ***@***.***> wrote:
Yep, I think that's a good idea. It should just be one .replace call with
a regex, the only question is how that would perform on bigger html strings
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#17 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ALsdfC090u649UJ4WfgWz2pGg-Fo8-S9ks5sH3C-gaJpZM4OEkg_>
.
|
@timsuchanek - I have a test branch working now, using acorn and acorn-jsx to parse. Unfortunately, it takes this lib from 9kb to 80kb or so - and I haven't found any good way to shake the extra size so far... Would love it if you could take a look at #19 |
Was this issue solved in #19? Tried the following snippet with import JsxParser from 'react-jsx-parser'
const MyComponent = () => (
<JsxParser
jsx={`
<h1>Header</h1>
<img src="someimage.png">
<span>Some other text</span>
`}
/>
) and the input <img src="someimage.png" /> Seen downstream in plotly/dash-core-components#746. |
@anders-kiaer having a tag without either a closing tag, or an end of To elucidate this, here's what happens when Acorn hits this kind of scenario: i.e. - we don't even get far enough along to process the node - we simply get a syntax error. So, unfortunately, to handle this situation, you need to ensure your snippets are valid JSX, not just valid HTML. |
Thanks for a quick answer @TroyAlford and clarification of scope 🙂
No problem 👍 We use |
Ooh, yeah that makes sense. And yep - that sounds like it's needed. :) Perhaps you could share your workaround snippet? I do already mirror which JSX components are |
I'm currently using
react-jsx-parser
with output of the remark parser. I just wanted to let you know, that theapplication/html+xml
has more problems than expected.It's pretty common that in html people forget to close tags like
<img src='img.png' >
.With
application/html+xml
this result in all tags coming after that tag to be ignored.What is your take on this? Should
react-jsx-parser
be that strict?For me unfortunately it's not an option as I can't rely on the html being compliant.
The text was updated successfully, but these errors were encountered: