beanumber
beanumber

Reputation: 777

syntax highlighting while rendering SQL using knitr

knitr will execute SQL code using engine='mysql' but not highlight syntax:

\documentclass{article}
\begin{document}
<<engine='mysql', engine.opts="-h localhost">>=
SHOW DATABASES;
@
\end{document}

On the other hand using engine='highlight' will highlight the code but not execute it.

\documentclass{article}
\begin{document}
<<engine='highlight', engine.opts='-S sql -O latex'>>=
SHOW DATABASES;
@
\end{document}

Is there a way to have the code executed and the syntax highlighted using one chunk?

Upvotes: 1

Views: 385

Answers (1)

Yihui Xie
Yihui Xie

Reputation: 30164

I just added support for syntax highlighting for the mysql engine in knitr. You can use knitr (>= 1.12.7), which is currently on Github.

Upvotes: 3

Related Questions