Skip to content
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

Support parsing elements with no closing tag #221

Closed
DGulshan opened this issue Oct 18, 2021 · 9 comments · Fixed by #276
Closed

Support parsing elements with no closing tag #221

DGulshan opened this issue Oct 18, 2021 · 9 comments · Fixed by #276
Labels
bug Something isn't working wontfix This will not be worked on

Comments

@DGulshan
Copy link

DGulshan commented Oct 18, 2021

I am trying to parse MJML that includes <br> tags, but I get the following error: invalid format. JavaScript parser for MJML doesn't seem to have to this issue. For example, the following MJML renders without any issues on https://mjml.io/try-it-live:

<mjml>
  <mj-body>
    <mj-section>
      <mj-column>
        <mj-text><br>Some Test Content</mj-text>
      </mj-column>
    </mj-section>
  </mj-body>
</mjml>

It works when I replace <br> with <br/> but I am trying to parse some external templates and in some of these templates, <br> tags have additional data attributes, so I can't do a simple find and replace.

Please let me know if this can be supported.

@jdrouet
Copy link
Owner

jdrouet commented Oct 19, 2021

Hi! Thank you for your issue.
This comes from the library I use to parse the template: xmlparser. <br> without a closing </br> is not a valid XML element BUT is still valid in HTML.
To fix that bug, I'd need to use a completely different XML parser which is out of scope for now.

@jdrouet jdrouet added bug Something isn't working wontfix This will not be worked on labels Oct 19, 2021
@DGulshan
Copy link
Author

Alright! Thanks for letting me know.

@RabidFire
Copy link

@jdrouet Thanks for the amazing crate! ❤️ Would love to pick your brain a bit more on this:

  1. As per the MJML docs, only mj-raw and mj-text tags allow HTML. Would it be better to:
    (a) use an HTML parser only for the children of mj-raw & mj-text? (OR)
    (b) replace xmlparser completely with an HTML parser?
  2. Would html5ever be a good HTML parser to use?
  3. Would you be open to merging a pull request with these changes?

Appreciate your time.

@nguyenquannnn
Copy link

Bump, Imo i think there's valid need for these. If @jdrouet can propose a direction, maybe migrating to a different parser can be work on :)

@paulgoetze
Copy link

@jdrouet would (some?) other void elements also needed to be ignored similar to br and meta? E.g. <hr> comes to mind, which might be used one or the other time.

https://html.spec.whatwg.org/multipage/syntax.html#void-elements

@jdrouet
Copy link
Owner

jdrouet commented Mar 25, 2022

@paulgoetze thanks for finding this! I'll update it!

@jdrouet
Copy link
Owner

jdrouet commented Mar 26, 2022

@paulgoetze done and released ;)

@marcelolx
Copy link

@jdrouet could we support the same for the mj-raw element? It looks like support for self closing elements was just added to the mj-wrapper?

@jdrouet
Copy link
Owner

jdrouet commented Mar 26, 2024

Hey,
Let me take a look when I have some time.
Could you open a new issue with an example?
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix This will not be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants