Yoav Raskin suggested that it would be useful to support right-to-left (RTL) documents in {emayili}
, so that languages like Hebrew, Arabic and Aramaic would render properly. Iโll be honest, this was not something that I had previously considered. But agreed, it would be a cool feature.
library(emayili)
packageVersion("emayili")
[1] '0.5.5'
RTL in CSS
The first step to make this happen was writing a short CSS file, rtl.css
.
.rtl {
direction: rtl;
color: green;
}
body {
margin: 20px 0px;
}
figure {
margin-bottom: 20px;
}
.rtl figcaption {
direction: inherit;
}
This makes use of the CSS direction
property (which by default is ltr
), setting it to rtl
. Iโm also colouring the RTL text in green, just to make things super clear.
I put together a simple .Rmd
file to test, rtl.Rmd
, rendered it into a message and then dispatched.
envelope() %>%
subject("Right-to-Left Text") %>%
render("rtl.Rmd", css_files = "rtl.css")
The extra CSS is included via the css_files
parameter.
๐จ If you want this to work nicely on Gmail then youโll also need to set include_css = c("rmd", "highlight")
because Gmail doesnโt currently appreciate Bootstrap CSS.
In the interests of brevity the contents of rtl.Rmd
have been appended to the end of the post.
And this is what the delivered email looks like:
Having a rtl
class allowed me to mix both left-to-right and right-to-left content in the same message. In reality this is a rather unlikely requirement. To use RTL for the entire message just adapt the CSS as follows:
body {
direction: rtl;
}
If there are other tweaks that I can make on {emayili}
to ensure that it supports your requirements, please raise an issue on the repository.
The
{emayili}
package is developed & supported by Fathom Data.Here are the contents of rtl.Rmd
:
--------
output: html_document
--------
{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer non magna
magna. Etiam eu sapien nulla. Cras ac lectus non urna scelerisque porttitor ac
non tortor.
<div class="rtl">
ืฆืืืง ืืืขืืืจืช, ืืืืืืื ืฉื ืืืจืืช ืืืืคืฉืืช. ืื ืจืืฆื ืืคืกืคืก, ืขืฆืื ืืืฆืจ ืืืืืจืืช, ืื
ืจื. ืขืืฉืื ืืืื ืฉื ืืืื ืืื ืื ืืืื ืฉื ืืืจืื, ืืฆืืจื ืฉื ืืืื ืืืืืื ืฉื ืืชืคืื.
ืืืื ื ืืืฉืื, โโืืื ืื ืืกืื ืืืื ืฉื ื ืื"ื, ืืจืืืช ืขืื ืฉื ืืืืื ืืื ืจืื ืื ืืืช, ืจืืข
ืืคื ื ืืกืคื ืืืืื. ืื ืืืก ืืื ืืืืจ ืจืืื ืืืืืจ. ืืื ืคืื ืืื ืื ืืืืืช ืื ืื. ืื ื ืื
ืืืืืกืจ ืืขืฆืื ืฉื ืืืืืจืื ืฉืื, ืืกืื ืืื ืืืืื. ืืื ืืืขื ื ืืืงืฉืชืืช, ืื ืงืฆืืช ืืืืจืงืื.
ืื ืืืื ืื ืืคื ืื. ืืืื ืฉื ืืขืืง ืืืงื. ืืคืืื ืืคืื ืืืคืื, ืืงืฉืชืืช ืื ืืืขืืืจืช, ืืชืช
ืืืื ืืจื ื.
</div>
{r pressure, out.width="50%", fig.cap="ืืืชืื ืืืืช", fig.class="rtl"}
par(mar = c(5, 4, 1, 1))
plot(pressure, xlab = "ืึถืืคึถึผืจึธืืึผืจึธื", ylab = "ืึทืึทืฅ", mar = c(5, 4, 0, 2))
<div class="rtl">
ืืืืื ื ืืฉืืช ืืช ืืกืืืจืืช ืืกืืฃ ืืฉืืืข, ืืืคืื ืืืืืืจืื ืงืฉื. ืืื ืืืจืื ืืืืจืื ืืืืืืื
ื ืืฆืืื ืืืืื. ืื ืืจืืื ืฆืจืื ืืืืื. ืืื ืืืืื ืชื, ืฆืจืืช ืืืืื ืืืชืืจืืช ืืจืื ืืืื,
ืืงืจืืงืืืจื ืืงืืงื ืืืจืืกืื. ืขืืฉืื ืื ื ืฉืื ื ืืช ืืืืจืืื, ืื ืืช ืืืื ืืื ืืช ืืกืืืื,
ืืื ืืกื ืงืื. ืขืืฉืื ืืื ืืกื ืืืื.
</div>
Cras fringilla nunc in tellus sagittis accumsan. Mauris nisi tellus, congue sit
amet turpis nec, accumsan lacinia neque. Nulla facilisi.
Top comments (0)