MySQL Documentation: Syntax Highlighting
Mysql 10-Jun-2017

MySQL Documentation: Syntax Highlighting

MySQL documentation has greatly improved code examples now: There's syntax highlighting in place, and code snippets can easily be copied to the clipboard. Highlighting is language-aware (including "languages" like the shell/command line). See, for example, this page from the X DevAPI documentation that contains a number of code examples for different programming languages.

Syntax highlighting is a project we planned a year ago, but it turned out to be more complex than we thought it would be. One of the major challenges was performance -- we didn't want the new function to slow down page loading, which is what many highlighting plugins do. Eventually, our striving Web team gave prism.js a try, which works like a charm and doesn't impact performance at all. The Web team also created a little management interface to be used by documentation writers. Its main functionality is to assign a language to each new code example. While most code is detected correctly by prism.js, there can be problematic cases, for example, mixes of various things like, say, shell, SQL, and Python.