Daily Archives: 2013-02-08


SQL syntax highlighter for PrismJS

After the Python highlighter, here is an SQL syntax highligher for PrismJS. Covering over 380 important keywords from the most famous SQL database implementations, such as MySQL, Microsoft SQL Server etc.

SQL Highlighting Sample


//one line comment
/* 
 * multiline 
 * comments
 */
SELECT Book.title 
 FROM Book
 JOIN Book_author ON Book.isbn = Book_author.isbn
 GROUP BY Book.title
HAVING Book.price > 10.4 AND Book_author.name = "Frank"
ORDER BY No_of_Authors ; -- another comment style

 
Until my GitHub fork merged with the original PrismJS project, you can download this add-on and use it with the existing PrismJS script, by putting it after the the prism.min.js script definition and by using the value language-sql at class property of the code element you like to highlight.

Usage

. . .
<script src="prism.min.js"></script>
<script src="prism-sql.min.js"></script>
. . .
<pre><code class="language-sql">
. . .

 
Download Prism SQL Higlighter