Skip to main content

Syntax Highlighting

Abstract

Syntax highlighting is when code samples use color-coding and indentations to make it easier to differentiate between parts of the code.

Syntax highlighting is when code samples use color-coding and indentations to make it easier to differentiate between parts of the code. In the following code extract, syntax highlighting is used to apply different colors to elements. The background is dark and different colors are used to highlight the different types of code element, for example, var declarations are light blue and the var names, such as icon1, are green.

Some example javascript shown with a black background. Each part of the code is colored differently.

Syntax highlighting works differently for HTML5 and PDF, but there are some common characteristics:

  • You can enable and disable syntax highlighting on the layout you use for publishing.

  • You choose the theme to use for syntax highlighting on the layout. There are many themes, each offering different colors and syntax highlighting.

  • Paligo can usually detect a code language in a verbatim element, such as programlisting, automatically. But if it is not recognizing your code sample, you can apply a language attribute and set the language there.

To get started, see: