rstudio/rmarkdown-cookbook

How to customize code chunks ouputs ?

cderv opened this issue · 3 comments

cderv commented

We could have some recipes on how to customize code chunk output.
The idea is to talk about

code > span.kw { color: #555; font-weight: bold; } /* Keyword */
code > span.dt { color: #902000; } /* DataType */
code > span.dv { color: #40a070; } /* DecVal (decimal values) */
code > span.bn { color: #d14; } /* BaseN */
code > span.fl { color: #d14; } /* Float */
code > span.ch { color: #d14; } /* Char */
code > span.st { color: #d14; } /* String */
code > span.co { color: #888888; font-style: italic; } /* Comment */
code > span.ot { color: #007020; } /* OtherToken */
code > span.al { color: #ff0000; font-weight: bold; } /* AlertToken */
code > span.fu { color: #900; font-weight: bold; } /* Function calls */
code > span.er { color: #a61717; background-color: #e3d2d2; } /* ErrorTok */
  • Apply custom formatting on a chunk basis using knitr class.source or class.output options and a CSS
  • deactivate highlighting with highlight=FALSE chunk option
  • Do not touch the highlighting but other style of the code chunk using by modifying with css html tag pre, code and/or class .r or others languages.

Also

  • Background color in latex through background chunk option
    I would find it useful to have all this in a cookbook to go from time to time as it is not well known I think.

Related SO questions

cderv commented

There is also now the class.warning, class.message and class.error.
Give examples about this