This extension contains functions for highlighting syntax of popular programming languages. Related Links: Extension Overview, DekiScript Overview, Extension Demos.
Assembly: mindtouch.deki.services
SID: http://services.mindtouch.com/deki/draft/2007/06/syntax
This service requires Deki Wiki 1.8.2 or later.
To enable this extension, follow these steps:
This extension is based on the work done by Alex Gorbatchev on the syntaxhighlighter project. Refer here for more information on how to embed this extension.
How to use the Syntax extension:
The easiest way to format text using the Syntax extension is to use the Transform menu: create a paragraph using the "formatted" style, paste or write the code you wish to format, then select the appropriate "syntax" transform from the toolbar menu.
Note in some editors the dropdown is not available, in that case you may need to have to apply the transform manually. Toggle to HTML/Source mode, find the <pre> element preceding the content to format, and change it to <pre class="script" function="syntax.php"> to apply the "syntax.php" transform function.
Once the transform is applied, the formatted paragraph will indicate that its content is dynamically generated. Save the page. Once the browser reloads, your content will be formatted with the function you selected.
Functions:
Highlight C/C++ syntax.
Parameters:
| Name | Type | Description |
| code | str | Source code to highlight. |
| collapse | bool | Optional. Collapse code view (default: false) |
| firstline | num | Optional. First line number (default: 1) |
Samples:
| Output | |
| To embed highlighted C/C++: #include <iostream.h>
main()
{
cout << "Hello World!" << endl;
return 0;
} |
Highlight C# syntax.
Parameters:
| Name | Type | Description |
| code | str | Source code to highlight. |
| collapse | bool | Optional. Collapse code view (default: false) |
| firstline | num | Optional. First line number (default: 1) |
Samples:
| Output | |
| To embed highlighted C#: using System;
class HelloWorld
{
public static int Main(String[] args)
{
Console.WriteLine("Hello, World!");
return 0;
}
} |
Highlight CSS syntax.
Parameters:
| Name | Type | Description |
| code | str | Source code to highlight. |
| collapse | bool | Optional. Collapse code view (default: false) |
| firstline | num | Optional. First line number (default: 1) |
Samples:
| Output | |
| To embed highlighted CSS: body:before {
content: "Hello World!";
} |
Highlight Delphi syntax.
Parameters:
| Name | Type | Description |
| code | str | Source code to highlight. |
| collapse | bool | Optional. Collapse code view (default: false) |
| firstline | num | Optional. First line number (default: 1) |
Samples:
| Output | |
| To embed highlighted Delphi: Program Hello_World;
{$APPTYPE CONSOLE}
Begin
WriteLn('Hello World!');
End. |
Highlight HTML syntax.
Parameters:
| Name | Type | Description |
| code | str | Source code to highlight. |
| collapse | bool | Optional. Collapse code view (default: false) |
| firstline | num | Optional. First line number (default: 1) |
Samples:
| Output | |
| To embed highlighted HTML: <HTML> <HEAD> <TITLE>Hello World!</TITLE> </HEAD> <BODY> Hello World! </BODY> </HTML> |
Highlight Java syntax.
Parameters:
| Name | Type | Description |
| code | str | Source code to highlight. |
| collapse | bool | Optional. Collapse code view (default: false) |
| firstline | num | Optional. First line number (default: 1) |
Samples:
| Outpu | |
| To embed highlighted Java: class HelloWorld {
static public void main( String args[] ) {
System.out.println( "Hello World!" );
}
} |
Highlight JavaScript syntax.
Parameters:
| Name | Type | Description |
| code | str | Source code to highlight. |
| collapse | bool | Optional. Collapse code view (default: false) |
| firstline | num | Optional. First line number (default: 1) |
Samples:
| Outpu | |
| To embed highlighted JavaScript: function Hello () {
alert("Hello World!");
} |
Highlight Perl syntax. (New in 1.8.3)
Parameters:
| Name | Type | Description |
| code | str | Source code to highlight. |
| collapse | bool | Optional. Collapse code view (default: false) |
| firstline | num | Optional. First line number (default: 1) |
Highlight PHP syntax.
Parameters:
| Name | Type | Description |
| code | str | Source code to highlight. |
| collapse | bool | Optional. Collapse code view (default: false) |
| firstline | num | Optional. First line number (default: 1) |
Samples:
| Outpu | |
| To embed highlighted PHP: <?php // Hello World in PHP echo 'Hello World!'; ?> |
Highlight Python syntax.
Parameters:
| Name | Type | Description |
| code | str | Source code to highlight. |
| collapse | bool | Optional. Collapse code view (default: false) |
| firstline | num | Optional. First line number (default: 1) |
Samples:
| Outpu | |
| To embed highlighted Python: print "Hello World!" |
Highlight Ruby syntax.
Parameters:
| Name | Type | Description |
| code | str | Source code to highlight. |
| collapse | bool | Optional. Collapse code view (default: false) |
| firstline | num | Optional. First line number (default: 1) |
Samples:
| Outpu | |
| To embed highlighted Ruby: puts "Hello World!" |
Highlight shell script syntax. (New in 1.8.3)
Parameters:
| Name | Type | Description |
| code | str | Source code to highlight. |
| collapse | bool | Optional. Collapse code view (default: false) |
| firstline | num | Optional. First line number (default: 1) |
Highlight SQL syntax.
Parameters:
| Name | Type | Description |
| code | str | Source code to highlight. |
| collapse | bool | Optional. Collapse code view (default: false) |
| firstline | num | Optional. First line number (default: 1) |
Samples:
| Outpu | |
| To embed highlighted SQL: SELECT 'Hello World!'; |
Highlight Visual Basic syntax.
Parameters:
| Name | Type | Description |
| code | str | Source code to highlight. |
| collapse | bool | Optional. Collapse code view (default: false) |
| firstline | num | Optional. First line number (default: 1) |
Samples:
| Outpu | |
| To embed highlighted Visual Basic: Private Sub Form_Load() Print "Hello World!" End Sub |
Highlight XML syntax.
Parameters:
| Name | Type | Description |
| code | str | Source code to highlight. |
| collapse | bool | Optional. Collapse code view (default: false) |
| firstline | num | Optional. First line number (default: 1) |
Samples:
| Outpu | |
| To embed highlighted XML: <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="HelloWorld.xsl" ?> <text><string>Hello World!</string></text> |