rstudio / blastula

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

rendered email contains script tags #323

Open aronatkins opened 8 months ago

aronatkins commented 8 months ago

Given the R Markdown file:

---
title: Something wonderful
---

Some of the content in this document makes its way to the rendered HTML and
some of it is destined for a custom email message. The email message
customizes the subject and the body of the email, while the rendered HTML
contains only this paragraph.

```{r echo = FALSE}
library(blastula)

blastula::attach_connect_email(
    email = blastula::render_connect_email(input = "email.Rmd"),
    subject = "Buy groceries (rmarkdown)",
    attach_output = FALSE,
    preview = FALSE
  )

and the accompanying `email.Rmd`:

````markdown
Remember to pick up groceries on you way home. Tonight is "breakfast for
dinner" and we're having French Toast!

* Bread
* Eggs
* Butter
* Milk

When rendered, the email message contains script tags and is not presented in some email clients. The gmail browser UI, for example, shows "[Message clipped]".

You can see this HTML by running:

result <- rmarkdown::render("index.Rmd")
md <- attr(result, "rmd_output_metadata", exact = TRUE)
writeLines(md$rsc_email_body_html, "email.html")

This may be an rmarkdown issue rather than a blastula problem, but filing here first.

aronatkins commented 8 months ago

Archive showing the email HTML file that was produced.

email.tar.gz

> packageVersion("blastula")
[1] ‘0.3.4’
> packageVersion("rmarkdown")
[1] ‘2.25’
aronatkins commented 7 months ago

The script only occurs if the email.Rmd lacks an explicit output. The email HTML does not contain script tags when blastula_email is used.

---
output: blastula::blastula_email
---

I totally missed the need to add an output format when creating my original example.

This may be a non-issue, as a result.