syntax highlighting while rendering SQL using knitr

Issue

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?

Solution

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.

Answered By – Yihui Xie

Answer Checked By – Marilyn (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.