Highlighting syntax in code

Warning

Specially formatted blocks work in both dynamic tables and pages built with the legacy editor.

Creating new pages in the legacy editor is no longer possible.

However, you can easily convert any existing pages from the legacy editor to the new editor format. For more information, see Switching a page to the new editor format.

You can highlight code syntax in Wiki pages. To do this, use the markup:

%%(<coding_language> nomark nohighlight)
source code
%%
Parameter Description
Coding language Programming language for highlighting syntax
nomark Optional parameter that disables line numbering
nohighlight Optional parameter that disables line numbering and syntax highlighting

Your browser's monospaced font is used for code highlighting in Wiki by default. You can change this font in your browser settings.

Supported programming languages

List of supported programming languages
Programming language Parameter
1C 1c, 1c
ActionScript actionscript
Apache apache
Applescript applescript
Bash bash, sh
C# c#, csharp, c-sharp
C++ c, cpp, c++
Closure closure
CMake cmake
Coffeescript coffeescript
CSP csp
Css css
D d
Delphi delphi
Diff diff
DOS .bat bat, dos
Django django
Dockerfile dockerfile
Erlang erlang
Erlang-repl erlang-repl
Go go
Haskell haskell
HTTP http
Ini ini
json json
Java java
Javascript js, javascript
Lisp lisp
Matlab matlab
Nginx nginx
ObjectiveC objc, objectivec, obj-c, objective-c
PHP php
Perl perl
Python py, python
Python profile profile, profiler, python-profile, python-profiler
R r
Ruby ruby
Rust rust
Scala scala
Smalltalk smalltalk
SQL mysql, sql
Swift swift
tex tex
vbscript vbscript
XML xml
YAML yaml, yml
YQL yql

Examples of source code formatting

Standard formatting

%%(php)
<?
phpinfo();
$s = "Hello, World!\n";
print $s;
%%
See the result

No line numbering

%%(python nomark)
@requires_authorization
def somefunc(param1, param2):
    r'''A docstring'''
    if param1 > param2: # interesting
       print 'Gre\'ater'
       print ''
    return (param2 - param1 + 1) or None

class SomeClass:
  pass
%%
See the result

No syntax highlighting

%%(code nohighlight)
@requires_authorization
def somefunc(param1, param2):
    r'''A docstring'''
    if param1 > param2: # interesting
        print 'Gre\'ater'
        print ''
    return (param2 - param1 + 1) or None

class SomeClass:
  pass
%%
See the result

Single-line code

Single-line source code that remains single-line after formatting.

%%(css)body {display: none;}%%
See the result