2015-01-05 57 views
3

knitr當針織.Rmd爲.html時自動生成鏈接。很多時候這很有用,但是現在不是我想要的。避免使用knitr自動生成超鏈接,降價

假設你有這樣的.Rmd文件:

--- 
title: "Doc title" 
output: html_document 
--- 

I don't want [email protected], but it comes out that way. 

If you wrap it in an R expression `r "[email protected]"`. 

Is there some kind of CSS trick I can avail myself of if I wanted <style='nolink'>www.something.com</style> not to be a link? 

針織這樣的:

library(knitr) 
knit2html('that_file.Rmd', 'that_file.html') 

結果在所有這些事情都是鏈接。

enter image description here

有沒有一種簡單的方法一般保持自動鏈接生成,但在某些特定行選擇禁用它?感謝您的任何想法。

編輯:我想我應該在接受之前嘗試下面的解決方案。這在.Rmd

I don't want this <!-- breaklink -->@to-be-a-link.com 

...實際上本身並沒有解析到一個HTML註釋,因爲 - 被改爲一個破折號,然後我得到(由knitr pandoc?):

enter image description here

+0

你只是不希望它顯示爲一個鏈接或完全刪除鏈接?另外,爲什麼你會使用R表達式,而不是在第二次嘗試中使用反引號? – A5C1D2H2I1M1N2O1R2T1

+0

這看起來很不好意思,但是你可以用類似於''的東西來「斷開」鏈接...... – A5C1D2H2I1M1N2O1R2T1

+0

因爲我想要純文本輸出,所以不想使用反引號版本。沒想到R表達式肯定會起作用,但只是顯示我試過/扔在牆上的東西。 – arvi1000

回答

4

我看到的兩個選項是(1)使用反引號,或者(2)使用空的HTML註釋「打破」鏈接。

例子:

--- 
title: "Doc title" 
output: html_document 
--- 

I don't want this<!-- -->@to-be-a-link.com, but it comes out that way. 

If you wrap it in an R expression `[email protected]`. 

Is there some kind of CSS trick I can avail myself of if I wanted 
<style='nolink'>http<!-- -->://www.something.com</style> not to 
be a link? 

變爲:

enter image description here

+1

@ arvi1000,好吧,這是一個評論 - 所以你可以把它做成冗長的,就像'this <! - breaklink - > @ to-be-a-link.com' :-) – A5C1D2H2I1M1N2O1R2T1