jimhester / knitrBootstrap

A framework to create bootstrap styled HTML reports from knitr Rmarkdown.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Code doesn't highltight

cpsievert opened this issue · comments

This probably isn't a real issue (just me being ignorant), but for some reason, I can't get proper code highlighting using the RStudio option:

options(rstudio.markdownToHTML =
  function(inputFile, outputFile) {
    require(knitrBootstrap)
    knit_bootstrap_md(input=inputFile, output=outputFile)
  }
)

I've also tried changing the default code_style option:

options(rstudio.markdownToHTML =
  function(inputFile, outputFile) {
    require(knitrBootstrap)
    knit_bootstrap_md(input=inputFile, output=outputFile, code_style='tomorrow')
  }
)

Not sure how I can provide a reproducible example, but here is what I'm working on. Also, I'm using RStudio version 0.98.313 and here is my sessionInfo:

R version 3.0.1 (2013-05-16)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] knitrBootstrap_0.8.0 markdown_0.6.3       knitr_1.5            dlm_1.1-3            XML2R_0.1           
[6] roxygen2_2.2.2       digest_0.6.3         devtools_1.3        

loaded via a namespace (and not attached):
 [1] brew_1.0-6     evaluate_0.5   formatR_0.9    httr_0.2       memoise_0.1    parallel_3.0.1 plyr_1.8       RCurl_1.95-4.1
 [9] stringr_0.6.2  tools_3.0.1    whisker_0.3-2  XML_3.95-0.2  

I am not at a computer so I can't be positive this is the problem, but it
looks like from your example you do not call the knitr render_markdown
function. Put that function in the first code block or in a setup block
and it should work. I will take a look at this and make sure I am correct
when I can. Sorry fir the problems, there is not a great way for me to fix
this particular issue transparently unfortunately.
On Oct 13, 2013 2:39 PM, "Carson" notifications@github.com wrote:

This probably isn't a real issue (just me being ignorant), but for some
reason, I can't get proper code highlighting using the RStudio option:

options(rstudio.markdownToHTML =
function(inputFile, outputFile) {
require(knitrBootstrap)
knit_bootstrap_md(input=inputFile, output=outputFile)
}
)

I've also tried changing the default code_style option:

options(rstudio.markdownToHTML =
function(inputFile, outputFile) {
require(knitrBootstrap)
knit_bootstrap_md(input=inputFile, output=outputFile, code_style='tomorrow')
}
)

Not sure how I can provide a reproducible example, but herehttps://github.com/cpsievert/cpsievert.github.com/tree/master/projects/615/HW4is what I'm working on. Also, I'm using RStudio version 0.98.313 and here
is my sessionInfo:

R version 3.0.1 (2013-05-16)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] knitrBootstrap_0.8.0 markdown_0.6.3 knitr_1.5 dlm_1.1-3 XML2R_0.1
[6] roxygen2_2.2.2 digest_0.6.3 devtools_1.3

loaded via a namespace (and not attached):
[1] brew_1.0-6 evaluate_0.5 formatR_0.9 httr_0.2 memoise_0.1 parallel_3.0.1 plyr_1.8 RCurl_1.95-4.1
[9] stringr_0.6.2 tools_3.0.1 whisker_0.3-2 XML_3.95-0.2


Reply to this email directly or view it on GitHubhttps://github.com//issues/25
.

I just tried that and it doesn't seem to help. I also pushed the changes to the input file to make sure I'm not missing something...

Sorry I told you the wrong function the first time. The function you need to call is knitr::render_html() Code highlighting in your example seems to work fine once you do that. My apologies, I should have proof read my email more thoroughly the first time.

Ah, yes. That was the issue. One more thing. I noticed that the cached code chunks aren't highlighted. Is there a workaround for that? My instinct would be to add echo=FALSE the cached chunk, then rewrite that chunk with eval=FALSE, but that is obviously not optimal.

That is just because the result is cached from before you added
render_html(). Just delete your cache and rerun and it will work properly.

On Sun, Oct 13, 2013 at 4:50 PM, Carson notifications@github.com wrote:

Ah, yes. That was the issue. One more thing. I noticed that the cached
code chunks aren't highlighted. Is there a workaround for that? My instinct
would be to add echo=FALSE the cached chunk, then rewrite that chunk with
eval=FALSE, but that is obviously not optimal.


Reply to this email directly or view it on GitHubhttps://github.com//issues/25#issuecomment-26226758
.

Awesome. Looks good now. Thanks!