【问题标题】:Knitr, convert to base64 and CSS styleKnitr,转换为 base64 和 CSS 样式
【发布时间】:2014-05-28 17:55:58
【问题描述】:

我对这个很棒的库(和 HTML)有点陌生,所以这可能是一个菜鸟问题。

我有一种情况,我无法弄清楚 - 如何在图像中添加一些 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

谢谢!

【问题讨论】:

    标签: html css r knitr


    【解决方案1】:

    试试这个:

    <style>
    .displayed { border: solid 1px; }
    </style>
    
    <img src="Rplot001.png" class="displayed">
    

    【讨论】:

    • 因为正则表达式发生 base64 转换:reg &lt;- "&lt;\\s*[Ii][Mm][Gg]\\s+[Ss][Rr][Cc]\\s*=\\s*[\"']([^\"']+)[\"']"
    猜你喜欢
    • 2021-05-11
    • 2020-02-09
    • 1970-01-01
    • 2014-08-06
    • 2012-12-29
    • 2013-06-26
    • 2016-04-27
    • 2014-09-25
    相关资源
    最近更新 更多