FelixSchwarz / mjml-python

Python implementation for MJML - a framework that makes responsive-email easy
MIT License
73 stars 16 forks source link

Whitespace gets stripped between text & link inside <mj-text /> #19

Closed mrcoles closed 1 year ago

mrcoles commented 2 years ago

This appears to be a bug inside mj-text rendering. If I run this code:

from mjml import mjml_to_html
print(mjml_to_html('<mjml><mj-body><mj-text>Hello <a href="#">world</a></mj-text></mj-body></mjml>')['html'].split('\n')[-3])

I get this output:

    <div style=""><div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#000000">Hello<a href="#">world</a></div></div>

The space between "Hello" and "<a" gets stripped during the parsing.

I haven’t been able to dive through the code enough, yet, but seems like the first children element inside this mj-text should have elem["tail"] == " " https://github.com/FelixSchwarz/mjml-stub/blob/main/mjml/elements/mj_text.py#L104