2016-02-26 44 views
2

我想使用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與絕對路徑?

感謝,

+2

你的代碼似乎對我很好。你使用什麼軟件包版本? – user5219763

+0

@ user5219763我認爲OP正在使用Windows,而在rmarkdown中,正斜槓被Windows上的反斜槓取代。 'css'參數應該採用本地文件;也許有必要向Github上的rmarkdown repo提交一個功能請求,以支持非本地資源。 –

+0

@Yihui我在rmarkdown文檔中看到Mathjax支持外部url,所以我認爲'css'也可以。但是,也許你是對的。我將在Github上發佈一個功能請求。 –

回答

2

從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並具有引導樣式。