Software and Code Documentation

8 min read

Syntax Highlighting

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.

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:

Syntax Highlighting for HTML5

To set up syntax highlighting for HTML5 outputs, use the settings on an HTML5 layout, and add attributes to the code sample if required:

  1. Select Layout in the top menu.

    Paligo displays a list of Layouts. The list is empty if there are no custom Layouts in your Paligo instance.

  2. Select the Layout you want to update or Create a Layout.

    Tip

    You can copy the URL of the Layout Editor and paste it into a new tab in your browser. This can be useful if you frequently switch between your Paligo content and the Layout settings.

  3. Select Verbatim (code and software) in the sidebar.

  4. Use the settings to set up syntax highlighting:

    • Highlight verbatim elements - Set the syntax highlighting feature to Enable (on) or Disable (off).

    • Highlight theme - Choose a theme. Each theme provides a different color scheme for syntax highlighting and may highlight different parts of the code. There are many different themes to choose from and we recommend that you experiment until you find the theme that best meets your requirements.

  5. Select Save.

  6. Paligo will usually be able to recognize the language in a code sample automatically and will apply the chosen theme for syntax highlighting. If Paligo is not recognizing your code sample, you can give the sample a language attribute. Paligo will then be able to identify the sample by the value that's set for the language attribute.

    To set the language for a code sample:

    1. Edit the topic that contains the code sample and select the verbatim element for the sample, for example, the programlisting element.

    2. In the Element attributes section, add the language attribute and enter a supported language as the value. For example, javascript. To find out what values are acceptable, see Syntax Highlighting Languages for HTML5.

  7. Select Save.

Syntax Highlighting Languages for HTML5

You can use the language attribute to give code samples a specific programming language. For example, you could give a programlisting element the language attribute and set its value to javascript.

To find out how to add the language attribute, see Syntax Highlighting for HTML5.

The following table shows the values that you can set for the language attribute. For some languages, you can use one of several values, and these are separated by a comma in the table. You should only enter one of the values, for example, for JavaScript you can enter either js or javascript or jsx.

Programming language

Value for the language attribute

1C

1c

4D

4d

ABNF

abnf

Access logs

accesslog

ActionScript

actionscript, as

Ada

ada

Alan

alan, i

AngelScript

angelscript, asc

Apache

apache, apacheconf

AppleScript

applescript, osascript

Arcade

arcade

ARM assembler

armasm, arm

AsciiDoc

asciidoc, adoc

AspectJ

aspectj

AutoHotkey

autohotkey

AutoIt

autoit

AVR assembler

avrasm

Awk

awk, mawk, nawk, gawk

Axapta

axapta

Bash

bash, sh, zsh

Basic

basic

BNF

bnf

Brainfuck

brainfuck, bf

C

h

C/AL

cal

C#

csharp, cs

C++

cpp, hpp, cc, hh, c++, h++, cxx, hxx

Cache Object Script

cos, cls

Cap’n Proto

capnproto, capnp

Clojure

clojure, clj

CMake

cmake, cmake.in

CoffeeScript

coffeescript, coffee, cson, iced

Coq

coq

Crmsh

crmsh, crm, pcmk

Crystal

crystal, cr

CSP

csp

CSS

css

Cypher (Neo4j)

cypher

D

d

Dart

dart

Delphi

delphi, dpr, dfm, pas, pascal, freepascal, lazarus, lpr, lfm

Diff

diff, patch

Django

django, jinja

DNS Zone file

dns, zone, bind

Dockerfile

dockerfile, docker

DOS

dos, bat, cmd

dsconfig

dsconfig

DTS (Device Tree)

dts

Dust

dust, dst

Dylan

dylan

EBNF

ebnf

Elixir

elixir

Elm

elm

Erlang

erlang, erl

Excel

excel, xls, xlsx

Extempore

extempore, xtlang, xtm

F#

fsharp, fs

FIX

fix

Fortran

fortran, f90, f95

Gams

gams, gms

GAUSS

gauss, gss

G-Code

gcode, nc

GDScript

godot, gdscript

Gherkin

gherkin

GN for Ninja

gn, gni

Go

go, golang

Golo

golo, gololang

Gradle

gradle

Grammatical Framework

gf

Groovy

groovy

Haml

haml

Handlebars

handlebars, hbs, html.hbs, html.handlebars

Haskell

haskell, hs

Haxe

haxe, hx

HTML, XML

xml, html, xhtml, rss, atom, xjb, xsd, xsl, plist, svg

HTTP

http, https

Hy

hy, hylang

Inform7

inform7, i7

Ini, TOML

ini, toml

IRPF90

irpf90

Java

java, jsp

JavaScript

javascript, js, jsx

JSON

json

Kotlin

kotlin, kt

Lasso

lasso, ls, lassoscript

LaTeX

tex

LDIF

ldif

Leaf

leaf

Less

less

Lisp

lisp

LiveCode Server

livecodeserver

LiveScript

livescript, ls

Lua

lua

Makefile

makefile, mk, mak

Markdown

markdown, md, mkdown, mkd

Mathematica

mathematica, mma, wl

Matlab

matlab

Maxima

maxima

Maya Embedded Language

mel

Mercury

mercury

mIRC Scripting Language

mirc, mrc

Mizar

mizar

Mojolicious

mojolicious

Monkey

monkey

Moonscript

moonscript, moon

N1QL

n1ql

Nginx

nginx, nginxconf

Nim

nimrod

Nix

nix

NSIS

nsis

Objective C

objectivec, mm, objc, obj-c

OCaml

ocaml, ml

OpenGL Shading Language

glsl

OpenSCAD

openscad, scad

Oracle Rules Language

ruleslanguage

Oxygene

oxygene

Parser3

parser3

Perl

perl, pl, pm

PF

pf, pf.conf

PHP

php, php3, php4, php5, php6, php7

Plaintext

plaintext, txt, text

Pony

pony

PostgreSQL & PL/pgSQL

pgsql, postgres, postgresql

PowerShell

powershell, ps, ps1

Processing

processing

Prolog

prolog

Properties

properties

Protocol Buffers

protobuf

Puppet

puppet, pp

Python

python, py, gyp

Python profiler results

profile

Q

k, kdb

QML

qml

R

r

Razor CSHTML

cshtml, razor, razor-cshtml

ReasonML

reasonml, re

RenderMan RIB

rib

RenderMan RSL

rsl

Roboconf

graph, instances

Robot Framework

robot, rf

RPM spec files

rpm-specfile, rpm, spec, rpm-spec, specfile

Ruby

ruby, rb, gemspec, podspec, thor, irb

Rust

rust, rs

SAS

SAS, sas

Scala

scala

Scheme

scheme

Scilab

scilab, sci

SCSS

scss

Shape Expressions

shexc

Shell

shell, console

Smali

smali

Smalltalk

smalltalk, st

Solidity

solidity, sol

SQL

sql

Stan

stan, stanfuncs

Stata

stata

STEP Part 21

p21, step, stp

Structured Text

iecst, scl, stl, structured-text

Stylus

stylus, styl

SubUnit

subunit

Supercollider

supercollider, sc

Swift

swift

Tcl

tcl, tk

Terraform (HCL)

terraform, tf, hcl

Test Anything Protocol

tap

Thrift

thrift

TP

tp

Twig

twig, craftcms

TypeScript

typescript, ts

Vala

vala

VB.Net

vbnet, vb

VBScript

vbscript, vbs

Verilog

verilog, v

VHDL

vhdl

Vim Script

vim

x86 Assembly

x86asm

XL

xl, tao

XQuery

xquery, xpath, xq

YAML

yml, yaml

Zephir

zephir, zep

Syntax Highlighting for PDF

Use a PDF layout to set up syntax highlighting for PDF:

  1. Select Layout in the top menu.

    Paligo displays a list of Layouts. The list is empty if there are no custom Layouts in your Paligo instance.

  2. Select the Layout you want to update or Create a Layout.

    Tip

    You can copy the URL of the Layout Editor and paste it into a new tab in your browser. This can be useful if you frequently switch between your Paligo content and the Layout settings.

  3. Select Verbatim (code and software) and choose Syntax Highlight.

  4. Use the settings to set up syntax highlighting for your PDF output:

    • Turn syntax highlight on - Set the syntax highlighting feature to Enabled (on) or Disabled (off).

    • Default language when no language attribute has been set - If the code samples in your topics do not have a language set, Paligo will usually be able to identify the language automatically. But if it cannot identify the language, it will assume the code sample is in the default language. Use this setting to define the default language.

    • Default style for syntax highlight - Choose a theme. Each theme provides a different color scheme for syntax highlighting and may highlight different parts of the code. We recommend that you experiment until you find the theme that best meets your requirements.

    Note

    The default language and default style are only used if a code sample does not have its own attributes set for language and style.

  5. Select Save.

  6. You can use the language attribute to give a code sample its own language and style settings that will be used instead of the defaults. This is useful if Paligo is unable to recognize the language automatically.

    1. Edit the topic that contains the code sample and select the verbatim element for the sample, for example, the programlisting element.

    2. In the Element Attributes Panel, add the language attribute and enter a supported language as the value. For example, javascript. To find out what values you can use, see Syntax Highlighting Languages for PDF.

    3. Add the role attribute and enter a supported theme name as the value. For example, role: fruity. This is an optional step. Typically, you would want all code samples to use the same theme for consistency, and so would set a default theme on the layout and not use the role attribute on individual code samples.

      Note

      You can set the value to any theme that is listed in the Default style for syntax highlight setting on the PDF layout editor.

  7. Select Save.

When you publish to PDF using the layout you edited, the PDF output will use syntax highlighting. If a code sample has its own language and role set, Paligo will apply those. If a code sample does not have its own language and role set, Paligo will attempt to identify the language automatically and will use the default theme. If Paligo cannot identify the language automatically, it will use the default language that is set in the layout.

Syntax Highlighting Languages for PDF

You can use the language attribute to give code samples a specific programming language. For example, you could give a programlisting element the language attribute and set its value to javascript.

To find out how to add the language attribute, see Syntax Highlighting for PDF.

The following table shows the values that you can set for the language attribute. For some languages, you can use one of several values, and these are separated by a comma in the table. You should only enter one of the values, for example, for JavaScript you can enter either js or javascript.

Language

Value for the language attribute

ABAP

abap

ABNF

abnf

ActionScript

as, actionscript

ActionScript 3

as3, actionscript3

Ada

ada, ada95, ada2005

ADL

adl

Agda

agda

Alloy

alloy

AmbientTalk

at, ambienttalk, ambienttalk/2

ANTLR

antlr

ANTLR with ActionScript Target

antlr-as, antlr-actionscript

ANTLR with C# Target

antlr-csharp, antlr-c#

ANTLR with CPP Target

antlr-cpp

ANTLR with Java Target

antlr-java

ANTLR with ObjectiveC Target

antlr-objc

ANTLR with Perl Target

antlr-perl

ANTLR with Python Target

antlr-python

ANTLR with Ruby Target

antlr-ruby, antlr-rb

ApacheConf

apacheconf, aconf, apache

APL

apl

AppleScript

applescript

Arduino

arduino

AspectJ

aspectj

Aspx-cs

aspx-cs

Aspx-vb

aspx-vb

Asymptote

asy, asymptote

Autohotkey

ahk, autohotkey

AutoIt

autoit

Awk

awk, gawk, mawk, nawk

Basemake

basemake

Bash

bash, sh, ksh, shell

Bash Session

console, shell-session

Batchfile

bat, batch, dosbatch, winbatch

BBCode

bbcode

BC

bc

Befunge

befunge

BlitzBasic

blitzbasic, b3d, bplus

BlitzMax

blitzmax, bmax

BNF

bnf

Boo

boo

Boogie

boogie

Brainfuck

brainfuck, bf

Bro

bro

BUGS

bugs, winbugs, openbugs

C

c:

C#

csharp, c#

C++

cpp, c++

CA65 Assembler

ca65

cADL

cadl

CAmkES

camkes, idl4

CBM BASIC V2

cbmbas

Ceylon

ceylon

CFEngine3

cfengine3, cf3

Cfstatement

cfs

ChaiScript

chai, chaiscript

Chapel

chsprl, chpl

Cheetah

cheetah, spitfire

Cirru

cirru

Clay

clay

Clojure

clojure, clj

ClojureScript

clohurescript, cljs

CMake

cmake

C-Objdump

c-objdump

COBOL

cobol

COBOLFree

cobolfree

Coffee-script

coffee-script, coffeescript, coffee

Coldfusion CFC

cfc

Coldfusion HMTL

cfm

Common Lisp

common-lisp, cl, lisp

Component Pascal

componentpascal, cp

Control, Debian Control

control, debcontrol

Coq

coq

Cpp-Objdump

cpp-objdump, c++-objdumb, cxx-objdump

CPSA

cpsa

Crmsh

crmsh, pcmk

Croc

croc

Cryptol

cryptol, cry

Csound Document

csound-document, csound-csd

Csound Orchestra

csound, csound-orc

Csound Score

csound-score, csound-sco

CSS

css

CSS+Django, CSS+Jinja

css+django, css+jinja

CSS+Erb, CSS+Ruby

css+erb, css+ruby

CSS+Genshitext, CSS+Genshi

css+genshitext, css+genshi

CSS+Lasso

css+lasso

CSS+Mako

css+mako

CSS+Mozpreproc

css+mozpreproc

CSS+Myghty

css+myghty

CSS+PHP

css+php

CSS+Smarty

css+smarty

CUDA

cuda, cu

Cypher

cypher

Cython

cython, pyx, pyrex

D

d

Dart

dart

Debian Sourcelist

sourceslist, sources.list, debsources

Delphi

delphi, pas, pascal, objectpascal

DG

dg

Diff

diff, udiff

Django/Jinja

django, jinja

D-Objdump

d-objdump

Docker

dockerfile, docker

Dpatch

dpatch

DTD

dtd

Duel

duel, jbst, jsonml+bst

Dylan

dylan

DylanLID

dylan-lid, lid

Dylan Session

dylan-console, dylan-repl

Earl Grey

earl-grey, earlgrey, eg

Easytrieve

easytrieve

EBNF

ebnf

eC

ec

ECL

ecl

Eiffel

eiffel

Elixir

elixir, ex, exs

Elixir iex session

iex

Elm

elm

EmacsLisp

emacs, elisp, emacs-lisp

ERB

erb

Erlang

erlang

Erlang ERL Session

erl

Evoque

evoque

Ezhil

ezhil

Factor

factor

Fancy

fancy, fy

Fantom

fan

Felix

felix, flx

Fish

fish, fishshell

Fortran

fortran

FortranFixed

fortranfixed

FoxPro, VFP, Clipper, XBase

foxpro, vfp, clipper, xbase

FSharp

fsharp

GAP

gap

GAS

gas, asm

Genshi

genshi, kid, xml+genshi, xml+kid

Genshi Text

genshitext

Gettext Catalog

pot, po

Gherkin

cucumber, gherkin

GLSL

glsl

Gnuplot

gnuplot

Go

go

Golo

golo

GoodData-CL

gooddata-cl

Gosu

gosu

Gosu Template

gst

Groff

groff, nroff, man

Groovy

groovy

Haml

haml

Handlebars

Handlebars

Haskell

haskell, hs

Haxe

hx, haxe, hxsl

Hexdump

Hexdump

HTML

html

HTML_Twig

html+twig

HTML+Cheetah

html+cheetah, html+spitfire, htmlcheetah

HTML+Django/Jinja

html+django, html+jinja, htmldjango

HTML+Evoque

html+evoque

HTML+Genshi

html+genshi, html+kid

HTML+Handlebars

html+handlebars

HTML+Lasso

html+lasso

HTML+Mako

html+mako

HTML+Myghty

html+myghty

HTML+PHP

html+php

HTML+Smarty

html+smarty

HTML+Velocity

html+velocity

HTTP

http

HXML

haxeml, hxml

Hy

hylang

Hybris

hybris, hy

IDL

idl

Idris

idris, idr

Igor

igor, igorpro

Inform 6

inform6, i6

Inform 6 template

i6t

Inform7, i7

inform7, i7

INI

ini, cfg, dosini

Io

io

Ioke

ioke, ik

IRC logs

irc

Isabelle

isabelle

J

j

Jade

jade

JAGS

jags

Jasmin

jasmin, jasminxt

Java

java

JavaScript

js, javascript

JavaScript+Cheetah

js+cheetah, javascript+cheetah, js+spitfire, javascript+spitfire

JavaScript+Django/Jinja

js+django, javascript+django, js+jinja, javascript+jinja

JavaScript+Genshitext,

js+genshitext, js+genshi, javascript+genshitext, javascript+genshi

JavaScript+Lasso

js+lasso, javascript+lasso

JavaScript+Mako

js+mako, javascript+mako

Javascript+Mozpreproc

javascript+mozpreproc

JavaScript+Myghty

js+myghty, javascript+myghty

JavaScript+PHP

js+php, javascript+php

Javascript+Ruby

js+erb, javascript+erb, js+ruby, javascript+ruby

JavaScript+Smarty

js+smarty, javascript+smarty

Java Server Page

jsp

JCL

jcl

JLCON Julia Console

jlcon

JSON

json

JSON-LD

jsonld, json-ld

Julia

julia, jl

Kal

kal

Kconfig

kconfig, menuconfig, linux-config, kernel-config

Koka

koka

Kotlin

kotlin

Lasso

lasso, lassoscript

Lean

lean

LessCSS

less

Lighttpd configuration

lighty, lighttpd

Limbo

limbo

Liquid

liquid

Literate Cryptol

lcry, literate-cryptol, lcryptol

Literate-Haskell

lhs, literate-haskell, lhaskell

Literate Idris

lidr, literate-idris, lidris

Literate Lagda

lagda, literate-agda

Live-Script

live-script, livescript

LLVM

llvm

Logos

logos

Logtalk

logtalk

LSL

lsl

Lua

lua

Makefile

make, makefile, mf, bsdmake

Mako

mako

MAQL

maql

Mask

mask

Mason

mason

Mathematica

mathematica, mma, nb

Matlab

matlab

Matlab session

matlabsession

MiniD

minid

Modelica

modelica

Modula-2

modula2, m2

MoinMoin/Trac Wiki markup

trac-wiki, moin

Monkey

monkey

MOOCode

moocode, moo

MoonScript

moon, moonscript

Mozhashpreproc

mozhashpreproc

Mozpercentpreproc

mozpercentpreproc

MQL

mql, mq4, mq5, mql4, mql5

Mscgen

mscgen, msc

MSDOS Session

doscon

MuPAD

mupad

MXML

mxml

Myghty

myghty

MySQL

mysql

NASM

nasm

Nemerle

nemerle

nesC

nesc

NewLisp

newlisp

Newspeak

newspeak

Nginx configuration

nginx

Nimrod

nimrod, nim

Nit

nit

Nix

nixos, nix

NSIS

nsis, nsi, nsh

NumPy

numpy

Objdump

objdump

Objdump-nasm

objdump-nasm

Objective-C

objective-c, objectivec, obj-c, objc

Objective-C++

objective-c++, objectivec++, obj-c++, objc++

Objective-J

objective-j, objectivej, obj-j, objj

OCaml

ocaml

Octave

octave

ODIN

odin

Ooc

ooc

Opa

opa

OpenEdge ABL

openedge, abl, progress

PacmanConf

pacmanconf

Pan

pan

Parasail

parasail

Pawn

pawn

Perl

perl, pl

Perl6

perl6, pl6

PHP

php, php3, php4, php5

Pig

pig

Pike

pike

PkgConfig

pkgconfig

plpgsql

PL/pgSQL

PostgreSQL

postgresql, postgres

PostgreSQL console

psql, postgresql-console, postgres-console

PostScript

postscript, postscr

POVRay

pov

PowerShell

powershell, posh, ps1, psm1

PowerShell Session

ps1con

Praat

praat

Prolog

prolog

Properties

properties, jproperties

Protocol Buffer

protobuf, proto

Puppet

puppet

Python 3

python3, py3

Python 3.0 Traceback

py3tb

Python console session

pycon

QBasic

qbasic, basic

QML

qml, qbs

QVTO

qvto, qvt

Racket

racket, rkt

Ragel

ragel

Ragel - Embedded

ragel-em

Ragel in C Host

ragel-c

Ragel in CPP Host

ragel-cpp

Ragel in D Host

ragel-d

Ragel in Java Host

ragel-java

Ragel in Objective C Host

ragel-objc

Ragel in Ruby Host

ragel-ruby, ragel-rb

Raw token data

raw

RConsole

rconsole, rout

Rd

rd

REBOL

rebol

Red

red, red/system

Redcode

redcode

Reg

registry

ResourceBundle

resource, resourcebundle

reStructuredText

rst, rest, restructuredtext

Rexx

rexx, arexx

RHTML

rhtml, html+erb, html+ruby

Roboconf Graph

roboconf-graph

Roboconf Instances

roboconf-instances

RobotFramework

robotframework

RPMSpec

spec

RQL

rql

RSL

rsl

Ruby

rb, ruby, duby

Ruby irb session

rbcon, irb

Rust

rust

S

splus, s, r

Sass

sass

Scala

scala

Scalate Server Page

ssp

Scaml

scaml

Scheme

scheme, scm

Scilab

scilab

SCSS

scss

Shen

shen

Slim

slim

Smali

smali

Smalltalk

smalltalk, squeak, st

Smarty

smarty

Snobol

snobol

SourcePawn

sp

SPARQL

sparql

SQL

sql

sqlite3con

sqlite3

SquidConf

squidconf, squid.conf, squid

Stan

stan

Standard ML

sml

SuperCollider

sc, supercollider

SWIG

swig

systemverilog

systemverilog, sv

TADS 3

tads3

TAP

tap

Tcl

tcl

Tcsh

tcsh, csh

Tea

tea

Termcap

termcap

Terminfo

terminfo

Terraform

terraform, tf

TeX

tex, latex

Text only

text

Thrift

thrift

Todotxt

todotxt

TrafficScript

rts, trafficscript

Treetop

treetop

Turtle

turtle

Twig

twig

TypeScript

ts, typescript

UrbiScript

urbiscript

Vala

vala, vapi

VB.net

vb.net, vbnet

VCTreeStatus

vctreestatus

Velocity

velocity

Verilog, v

verilog, v

VGL

vgl

vhdl

vhdl

VimL

vim

X10

x10, xten

XML

xml

XML+Cheetah

xml+cheetah, xml+spitfire

XML+Django/Jinja

xml+django, xml+jinja

XML+Evoque

xml+evoque

XML+Lasso

xml+lasso

XML+Mako

xml+mako

XML+Myghty

xml+myghty

XML+PHP

xml+php

XML+Ruby

xml+erb, xml+ruby

XML+Smarty

xml+smarty

XML+Velocity

xml+velocity

XSLT

xslt

xsltXQuery

xquery, xqy, xq, xql, xqm

Xtend

xtend

XUL+mozpreproc

xul+mozpreproc

YAML

yaml

YAML+Jinja

yaml+jinja, salt, sls

Zephir

zephir