Skip to content

Commit

Permalink
the syntax highlighter has been moved to highr
Browse files Browse the repository at this point in the history
  • Loading branch information
yihui committed Sep 1, 2014
1 parent ac25d13 commit 98d7298
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 16 deletions.
28 changes: 14 additions & 14 deletions inst/examples/knitr-manual.Rnw
Expand Up @@ -209,19 +209,19 @@ dedicated to specific features such as graphics in the website: \url{http://yihu

\subsection{Code Decoration}

An internal syntax highlighter is used to highlight R code, and the
\textbf{formatR} package \citep{R-formatR} is used to reformat R
code (like \texttt{keep.source=FALSE} in Sweave but will also try
to retain comments). For \LaTeX{} output, the \textbf{framed} package
is used to decorate code chunks with a light gray background. If this
\LaTeX{} package is not found in the system, a version will be copied
directly from \textbf{knitr}. The prompt characters are removed by
default because they mangle the R source code in the output and make
it difficult to copy R code. The R output is masked in comments by
default based on the same rationale. It is easy to revert to the output
with prompts (set option \texttt{prompt=TRUE}), and you will quickly
realize the inconvenience to the readers if they want to copy and
run the code in the output document:
The \textbf{highr} package \citep{R-highr} is used to highlight R
code, and the \textbf{formatR} package \citep{R-formatR} is used
to reformat R code (like \texttt{keep.source=FALSE} in Sweave but
will also try to retain comments). For \LaTeX{} output, the \textbf{framed}
package is used to decorate code chunks with a light gray background.
If this \LaTeX{} package is not found in the system, a version will
be copied directly from \textbf{knitr}. The prompt characters are
removed by default because they mangle the R source code in the output
and make it difficult to copy R code. The R output is masked in comments
by default based on the same rationale. It is easy to revert to the
output with prompts (set option \texttt{prompt=TRUE}), and you will
quickly realize the inconvenience to the readers if they want to copy
and run the code in the output document:

<<stupid-prompts, prompt=TRUE, comment=NA, highlight=FALSE>>=
x=rnorm(5)
Expand Down Expand Up @@ -706,7 +706,7 @@ and questions can be delivered to the \href{mailto:knitr@googlegroups.com}{maili
% when knitr is updated, this chunk will be updated; why?
<<auto-bib, version=packageVersion('knitr'), echo=FALSE, cache=TRUE, message=FALSE, warning=FALSE>>=
# write all packages in the current session to a bib file
write_bib(c(.packages(), 'evaluate', 'formatR'), file = 'knitr-packages.bib')
write_bib(c(.packages(), 'evaluate', 'formatR', 'highr'), file = 'knitr-packages.bib')
@

\bibliographystyle{jss}
Expand Down
16 changes: 14 additions & 2 deletions inst/examples/knitr-manual.lyx
Expand Up @@ -813,7 +813,18 @@ Code Decoration
\end_layout

\begin_layout Standard
An internal syntax highlighter is used to highlight R code, and the
The
\series bold
highr
\series default
package
\begin_inset CommandInset citation
LatexCommand citep
key "R-highr"

\end_inset

is used to highlight R code, and the
\series bold
formatR
\series default
Expand Down Expand Up @@ -2932,7 +2943,8 @@ SE, warning=FALSE>>=

\begin_layout Plain Layout

write_bib(c(.packages(), 'evaluate', 'formatR'), file = 'knitr-packages.bib')
write_bib(c(.packages(), 'evaluate', 'formatR', 'highr'), file = 'knitr-packages.b
ib')
\end_layout

\begin_layout Plain Layout
Expand Down
7 changes: 7 additions & 0 deletions inst/examples/knitr-packages.bib
Expand Up @@ -49,6 +49,13 @@ @Manual{R-ggplot2
url = {http://ggplot2.org, https://github.com/hadley/ggplot2},
year = {2014},
}
@Manual{R-highr,
title = {highr: Syntax highlighting for R},
author = {Yihui Xie and Yixuan Qiu},
year = {2013},
note = {R package version 0.3},
url = {http://CRAN.R-project.org/package=highr},
}
@Manual{R-knitr,
title = {knitr: A general-purpose package for dynamic report generation in R},
author = {Yihui Xie},
Expand Down

0 comments on commit 98d7298

Please sign in to comment.