blastula icon indicating copy to clipboard operation
blastula copied to clipboard

rendered email contains script tags

Open aronatkins opened this issue 6 months ago • 2 comments

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:

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 avatar Jan 10 '24 14:01 aronatkins