2014-04-14 45 views
2

我对这个伟大的库(和HTML)有点新,所以这可能是一个noob问题。Knitr,转换为base64和CSS样式

我有一种情况,我无法弄清楚 - 我怎样才能添加一些CSS样式的图像,同时也在base64编码它?这是我Rmarkdown文件中的代码(我传递给knit2html) -

<img src="SomeImage.png", width = "75%", border = "2"> # converts to base64 with width and border correctly applied 
<img class="displayed", src="SomeImage.png"> # does not convert to base64, points to local path with style correctly applied 

有没有什么办法让第二个转换为Base64同时应用样式吗?或者我做错了什么?

SessionInfo,如果需要的话 -

> sessionInfo() 
R version 3.0.2 (2013-09-25) 
Platform: x86_64-w64-mingw32/x64 (64-bit) 

other attached packages: 
[1] markdown_0.6.5 xtable_1.7-1  knitr_1.5  audio_0.1-4  ggplot2_0.9.3.1 
[6] scales_0.2.3  stringr_0.6.2 reshape2_1.2.2 reshape_0.8.4 plyr_1.8   
[11] data.table_1.9.2 

谢谢!

回答

1

试试这个:

<style> 
.displayed { border: solid 1px; } 
</style> 

<img src="Rplot001.png" class="displayed"> 
+0

大,工程。但我不明白为什么。 – TheComeOnMan

+2

由于base64转换发生在正则表达式中:'reg < - “<\\ s * [Ii] [Mm] [Gg] \\ s + [Ss] [Rr] [Cc] \\ s * = \\ s * [\ “']([^ \” '] +)[\“'​​]”' – kohske