mjml icon indicating copy to clipboard operation
mjml copied to clipboard

HTML Comments rendered with additional white space

Open gglnx opened this issue 1 year ago • 3 comments

Describe the bug Currently, HTML comments get additional whitespace inside in the beginning and the end: <!--#TEST--> will be transformed to <!-- #TEST -->. CleverReach uses HTML comments as a programming language and doesn't support a space or any other whitespace character between the start of the comment and the command (<!--#loop #--> works, <!-- #loop # --> not).

To Reproduce Steps to reproduce the behavior:

  1. Create a file with this MJML code: <mjml><!--#COMMAND#--></mjml>
  2. Render it to HTML and compare it

Expected behavior Preserving of no or all whitespaces in HTML comments.

MJML environment (please complete the following information):

  • OS: MacOS
  • MJML Version: 4.15.3
  • MJML tool used: mjml-cli

gglnx avatar Jul 09 '24 18:07 gglnx

Did you tried to wrap in mj-raw those comment ?

iRyusa avatar Jul 30 '24 09:07 iRyusa

Yes, to temporarily fix it. But I would like to prefer it, that MJML doesn't modify the whitespace inside an HTML comment.

gglnx avatar Jul 30 '24 10:07 gglnx

Might be fixable as the space might be introduced by this https://github.com/mjmlio/mjml/blob/master/packages/mjml-parser-xml/src/index.js#L315-L326

I'll check later

iRyusa avatar Jul 30 '24 10:07 iRyusa