jdrouet / mrml

Implementation of mjml in rust
MIT License
322 stars 19 forks source link

Support parsing elements with no closing tag in `mj-raw` #402

Closed marcelolx closed 3 months ago

marcelolx commented 3 months ago

Similar to what was done for https://github.com/jdrouet/mrml/issues/221, but support it for elements within a mj-raw element

We currently use the mrml through the ruby library and have found out that if you have a br element within the mj-raw it errors out with unexpected end of stream (MRML::Error).

Output:

Loading development environment (Rails 7.1.3.2)
"> mjml = <<-HTML
"> <mjml>
">   <mj-body>
">    <mj-raw>something<br>else</mj-raw>
">  </mj-body>
"> </mjml>
>> HTML
=> "<mjml>\n  <mj-body>\n   <mj-raw>something<br>else</mj-raw>\n </mj-body>\n</mjml>\n"
>> MRML.to_html(mjml)
/Users/marcelolx/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/mrml-1.5.0-arm64-darwin/lib/mrml.rb:26:in `new': unexpected end of stream (MRML::Error)
>> template = MRML::Template.new(mjml)
(irb):9:in `new': unexpected end of stream (MRML::Error)

If we change the line <mj-raw>something<br>else</mj-raw> to <mj-wrapper>something<br>else</mj-wrapper> it parses the br element successfully.


Ruby library version: v1.5.0 MRML version: v3

jdrouet commented 3 months ago

👋 It's fixed in the version 3.1.4 😉

marcelolx commented 3 months ago

Very much appreciated @jdrouet!

jdrouet commented 3 months ago

thanks a lot to you!