rstudio / blastula

Easily send great-looking HTML email messages from R
https://pkgs.rstudio.com/blastula
Other
548 stars 85 forks source link

MathJax in emails #254

Open dmi3kno opened 3 years ago

dmi3kno commented 3 years ago

Hi, Thank you for the package! This has a promise of making scientific emailing easy and enjoyable! I am trying to incorporate math formulas into my emails and I understand that it is turned off (mathjax=null) in the template. I tried turning it on (mathjax="default") and then rmarkdown complains

#> Warning message:
#> MathJax doesn't work with self_contained when not using the rmarkdown "default" template. 

There's this closed issue in rmarkdown that suggests it should be possible to work around the default template limitation. One solution could be to start blastula template from "default" and subsequently modify it into the form envisaged by the package. I tried supplying the "default" template argument, but of course I just get an unreadable wall of text instead of an email.

Did you ever look into what it would take to enable mathjax in blastula? Can we at least catch the equation tags, created by $mathjax$ and change the font to Serif?

cderv commented 3 years ago

For reference, the issue mentioned above is : https://github.com/rstudio/rmarkdown/issues/727

Some improvement needs to be done in rmarkdown regarding math support, to follow Pandoc updates on this. It is possible that this can help with self-contained document and remove the constraint. So maybe help for blastula ? I don't really know if a lib like mathjax can work inside email though... 🤔

Anyway, happy to think about it if things need to be done in rmarkdown.

dmi3kno commented 1 year ago

The main reason I use blastula is to send academic emails and they are sort of useless without math. Could we please brainstorm how it could be possible to create a self-contained document with mathjax, please?

cderv commented 1 year ago

@rich-iannone I think we can make time for that in the coming weeks. Don't you think ?

cderv commented 1 year ago

@dmi3kno you can try the PR

pak::pak("rstudio/blastula@math-support")

This is a POC of what is really easy to do to bring support in a rmarkdown format. I don't know at all if that works good for email at the end.

As you'll see in PR description there is a second solution possible - if that is supported for email. This require testing as it would require inserting a CSS inline if possible.

Anyway, thanks for pinging us again - this motivate me to make a quick try.

rich-iannone commented 1 year ago

Thanks @cderv for this work! It's looking really good so far in the PR. I will test it out with live emails (I can show you some of this in a meeting).