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

Elements intended to contain plain text shouldn't include leading/trailing space #2443

Closed
rootwork opened this issue Mar 15, 2022 · 4 comments

Comments

@rootwork
Copy link

rootwork commented Mar 15, 2022

Describe the bug

When using elements intended to contain only plain text -- like <mj-title> and <mj-preview> -- a space is prepended and appended to the text. In some cases (such as a rendered <title> tag in a client's browser window) this space can be noticeable.

To Reproduce

This is visible on the docs' Try It Live for both <mj-title> and <mj-preview>, but here's one that shows both:
https://mjml.io/try-it-live/qvxPFIRrv

View the HTML and then look at the <title> tag and further down the <div style="display:none... line.

Expected behavior
For MJML elements that are intended to contain only plain text -- I think it's just <mj-title> and <mj-preview>, but maybe also <mj-raw> in some situations? -- no spaces should be added before or after the contents. For other elements which typically wrap HTML tags, it's not necessary (and also usually collapsed by client rendering anyway).

If the space is for some reason desired in some situations, it would be nice to have attributes on these elements to optionally prevent it. Something like spaceless="true" or whitespace="none".

MJML environment (please complete the following information):

  • OS: Linux, but visible on Try It Live
  • MJML Version: 4.12.0
  • MJML tool used: npm package with gulp
@iRyusa
Copy link
Member

iRyusa commented Mar 16, 2022

Really weird that we have this issue only on those two tags. Looks to be related to beautify ?

@rootwork
Copy link
Author

It could be happening on other tags too, but as I said it wouldn't generally matter if the tag contains content that is wrapped in HTML. e.g. if it ends up generating <td> <p>..., clients/browsers will collapse that space. But if it's <td> Text... then it won't be collapsed.

@iRyusa
Copy link
Member

iRyusa commented Mar 17, 2022

There's no actual reason to have this whitespace anyway, i'll check if we can do something about this.

iRyusa added a commit that referenced this issue Jul 8, 2022
iRyusa added a commit that referenced this issue Aug 2, 2022
@iRyusa
Copy link
Member

iRyusa commented Sep 4, 2022

Looks fixed finally in latest version 😄

@iRyusa iRyusa closed this as completed Sep 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants