2014-04-14 46 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