从CDN使用Rmarkdown与CSS
问题描述:
我想使用CDN的引导CSS(http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css)创建Rmarkdown。从CDN使用Rmarkdown与CSS
我试图做到这一点,但它没有工作......
这是我尝试过(我试过不使用NULL,没有“”过,但我有同样的错误)
---
title: "Habits"
output:
html_document:
theme: NULL
highlight: NULL
css: "http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"
---
产生的错误是:
"E:/Program Files/R/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS teste.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output teste.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template "C:\Users\diego\Documents\R\win-library\3.2\rmarkdown\rmd\h\default.html" --css "http:\\maxcdn.bootstrapcdn.com\bootstrap\3.3.6\css\bootstrap.min.css" --mathjax --variable "mathjax-url:https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" --no-highlight
output file: teste.knit.md
pandoc.exe: Could not fetch http:\\maxcdn.bootstrapcdn.com\bootstrap\3.3.6\css\bootstrap.min.css
InvalidUrlException "http:%5C%5Cmaxcdn.bootstrapcdn.com%5Cbootstrap%5C3.3.6%5Ccss%5Cbootstrap.min.css" "URL must be absolute"
Error: pandoc document conversion failed with error 67
Besides that: Warning message:
command execution '"E:/Program Files/R/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS teste.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output teste.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template "C:\Users\diego\Documents\R\win-library\3.2\rmarkdown\rmd\h\default.html" --css "http:\\maxcdn.bootstrapcdn.com\bootstrap\3.3.6\css\bootstrap.min.css" --mathjax --variable "mathjax-url:https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" --no-highlight' teve status 67
Execution interrupted
有一些方法来指在线CSS与绝对路径?
感谢,
答
从Rmarkdown Github的成员@jjallaire:
的CSS选择外部URL不支持,但你可以这样做,而不是:
---
title: "Habits"
output:
html_document:
theme: NULL
highlight: NULL
---
<style type="text/css">
@import url("http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css");
</style>
—
编辑: 我在Rmarkdown页面找到的另一种解决方案:
---
title: "Habits"
output:
html_document:
theme: flatly
highlight: tango
---
平坦地来自Bootstrap并具有引导样式。
你的代码似乎对我很好。你使用什么软件包版本? – user5219763
@ user5219763我认为OP正在使用Windows,而在rmarkdown中,正斜杠被Windows上的反斜杠取代。 'css'参数应该采用本地文件;也许有必要向Github上的rmarkdown repo提交一个功能请求,以支持非本地资源。 –
@Yihui我在rmarkdown文档中看到Mathjax支持外部url,所以我认为'css'也可以。但是,也许你是对的。我将在Github上发布一个功能请求。 –