To use the syntax highlighter, first make sure the appropriate extension is installed. Then, use the "Formatted" format from the editor toolbar to create a <pre> section. Type or paste in your source code into the <pre> section. Now, click on "Transformations" and select the desired function (e.g. syntax.xml). The transformation is only applied when the page is viewed. So you will need to save the page to see the results.
Below are samples of the various syntax highlighter functions.
string url = "<a href=\"" + someObj.getUrl() + "\" target=\"_blank\">";
// single line comments
// second single line
override protected void OnLoad(EventArgs e)
{
if(Attributes["class"] != null)
{
//_year.CssClass = _month.CssClass = _day.CssClass = Attributes["class"];
}
base.OnLoad(e);
}
/***********************************
** Multiline block comments
**********************************/
/// <summary>
/// Gets or sets currently selected date of birth or <see cref="DateTime.MinValue"/> if selection is incomplete or invalid.
/// </summary>
public DateTime Date
{
String stringWithUrl = "http://blog.dreamprojections.com";
get
{
#region Hello world /* shouldn't be a comment */
try
{
/*
DateTime result = new DateTime(
int.Parse(_year.SelectedItem.Value),
// int.Parse(_month.SelectedItem.Value),
int.Parse(_day.SelectedItem.Value)
);
i *= 2;
*/
return result;
}
catch
{
/* return _minDate; */
}
#endregion
}
set
{
Day = value.Day;
Month = value.Month;
Year = value.Year;
}
}
#include <windows.h>
#include "winevent.hpp"
#include <time.h>
#include <stdio.h>
int nInt = 0;
int nStart = 0;
int nEnd = 0;
char buf[255];
//////////////////////////////////////////////////////////////
// Event handlers
template<>
LRESULT OnMsg<WM_CREATE>(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
strcpy(buf, "Press any key to start test");
return DefWindowProc(hWnd, WM_CREATE, wParam, lParam);
}
template<>
LRESULT OnMsg<WM_KEYDOWN>(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
nInt = 0;
strcpy(buf, "running test, please wait ...");
InvalidateRect(hWnd, NULL, true);
SendMessage(hWnd, WM_PAINT, 0, 0);
nStart = GetTickCount();
PostMessage(hWnd, WM_TIMER, 0, 0);
return DefWindowProc(hWnd, WM_KEYDOWN, wParam, lParam);
}
template<>
LRESULT OnMsg<WM_TIMER>(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
if (nInt++ < 100000) {
PostMessage(hWnd, WM_TIMER, 0, 0);
} else {
nEnd = GetTickCount();
sprintf(buf, "Time elapsed = %d msec",
((nEnd - nStart) * 1000) / CLOCKS_PER_SEC);
InvalidateRect(hWnd, NULL, true);
}
return 0;
}
template<>
LRESULT OnMsg<WM_DESTROY>(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
PostQuitMessage(0);
return 0;
}
template<>
LRESULT OnMsg<WM_PAINT>(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
hdc = BeginPaint(hWnd, &ps);
TextOut(hdc, 100, 100, buf, static_cast<int>(strlen(buf)));
EndPaint(hWnd, &ps);
return DefWindowProc(hWnd, WM_PAINT, wParam, lParam);
}
/****************************************************
// Entry point for the application.
****************************************************/
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance, LPSTR szCmdLine, int nCmdShow)
{
InitMsgHandlers<NULL>();
static char szAppName[] = "demo";
HWND hwnd;
MSG msg;
WNDCLASSEX wndclass;
wndclass.cbSize = sizeof(wndclass);
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wndclass.lpszClassName = szAppName;
wndclass.lpszMenuName = NULL;
RegisterClassEx(&wndclass);
hwnd = CreateWindow(szAppName, "Static Dispatch Demo",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInstance, NULL);
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while ( GetMessage(&msg, NULL, 0, 0) ) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return static_cast<int>(msg.wParam);
}
/* Main style for the table */
.dp-highlighter
{
font-family: "Courier New", Courier, mono;
font-size: 12px;
text-align: left;
border: 1px solid #2B91AF;
background-color: #fff;
width: 99%;
overflow: auto;
line-height: 100% !important;
margin: 18px 0px 18px 0px;
}
.dp-highlighter ol
{
margin: 0px 0px 0px 45px;
padding: 0px;
color: #2B91AF;
}
.dp-highlighter ol li
{
border-left: 3px solid #6CE26C;
border-bottom: 1px solid #eee;
background-color: #fff;
padding-left: 10px;
}
.dp-highlighter ol li.alt
{
background-color: #f8f8f8;
}
{$IFDEF VER140}
(***********************************
** Multiline block comments
**********************************)
procedure TForm1.Button1Click(Sender: TObject);
var
Number, I, X: Integer;
Y: Integer;
begin
str := 'http://blog.dreamprojections.com';
Number := 12356;
Caption := 'The Number is ' + IntToStr(Number);
for I := 0 to Number do
begin
Inc(X);
{
Dec(X);
X := X * 1.0;
}
Y := $F5D3;
ListBox1.Items.Add(IntToStr(X));
(*
ShowMessage('Hello'); *)
end;
asm
MOV AX,1234H
// MOV Number,AX
end;
end;
package us.prokhorenko.jx;
import us.prokhorenko.jx.Person;
import org.exolab.castor.xml.*;
import java.io.*;
import java.util.*;
public class Test {
public static void main(String args[]) {
try {
/***********************************
** Multiline block comments
**********************************/
string stringWithUrl1 = "http://blog.dreamprojections.com";
// Marshalling class to XML
// Create the Person class
Person person = new Person("Mr. White", "mr@white", "626-555-1234");
// Marshal and save to XML file
FileWriter file = new FileWriter("person.xml");
Marshaller m = new Marshaller(file);
m.marshal(person);
file.close();
// Unmarshalling XML to class
// Read from XML and unmarshal
FileReader uFile = new FileReader("person.xml");
Unmarshaller u = new Unmarshaller();
Person uPerson = (Person)u.unmarshal(Person.class, uFile);
// Show name and email
System.out.println("name: " + uPerson.getName());
System.out.println("email: " + uPerson.getEmail());
} catch (Exception e) {
e.printStackTrace();
}
}
}
/***********************************
** Multiline block comments
**********************************/
// Hang test à partir de l`idagence / id type publication ``````
var stringWithUrl1 = "http://blog.dreamprojections.com";
var stringWithUrl2 = 'http://www.dreamprojections.com';
// callback for the match sorting
dpSyntaxHighlighter.prototype.SortCallback = function(m1, m2)
{
// sort matches by index first
if(m1.index < m2.index)
return -1;
else if(m1.index > m2.index)
return 1;
else
{
/*
// if index is the same, sort by length
if(m1.length < m2.length)
return -1;
else if(m1.length > m2.length)
return 1;
*/
}
alert('hello // world');
return 0;
}
/***********************************
** Multiline block comments
**********************************/
$stringWithUrl = "http://blog.dreamprojections.com";
$stringWithUrl = 'http://www.dreamprojections.com';
ob_start("parseOutputBuffer"); // Start Code Buffering
session_start();
function parseOutputBuffer($buf) {
global $portal_small_code, $portal_gzcompress;
global $PHP_SELF, $HTTP_ACCEPT_ENCODING;
// cleaning out the code.
if($portal_small_code && !$portal_gzcompress) {
$buf = str_replace(" ", "", $buf);
$buf = str_replace("\n", "", $buf);
$buf = str_replace(chr(13), "", $buf);
}
}
"""
Comment\"
string
"""
cache = {}
string s = "## comments inside a string"
string str = "helllo \"world\", how things?" + 10 + "word" + "hello" # and " some more here
def arrange(plans, lines, totalMinutes):
"""arrangements of plans taken lines times with an heuristic that the sum
of values in one arrangement is less then totalMinutes
"""
#if in cache we are done otherwise start calculating and save them to cache
if (plans, lines, totalMinutes) in cache:
return cache[(plans, lines, totalMinutes)]
if lines==1:
r = [[plan] for plan in plans]
cache[(plans, lines, totalMinutes)] = r
return r
solutions = []
for plan in plans:
for ar in sort(list(arrange(plans, lines-1, totalMinutes))):
try:
one_solution = tuple(sort([plan] + list(ar)))
if sum(one_solution) <= totalMinutes and one_solution not in solutions:
solutions.append(one_solution)
except Exception, e:
print "Error:", str(e)
cache[(plans, lines, totalMinutes)] = solutions
return solutions
if __name__ == "__main__":
import sys
lines, totalMinutes = int(sys.argv[1]), int(sys.argv[2])
plans = tuple([int(p) for p in sys.argv[3:]])
print "for", lines, totalMinutes, plans
for sol in arrange(plans, lines, totalMinutes):
print sol
# {tagname} {tagfile} {tagaddress}[;" {tagfield}..]
# "A tagfield has a name, a colon, and a value: "name:value".
# The name of the "kind:" field can be omitted. A program reading the
# tags file can recognize the "kind:" field by the missing ':'.
class Parser
@@parsers = []
def get_type()
return ""
end
def parse( xml )
@var = nil
return nil
end
def Parser.add_parser( :symlink )
@@parsers.push( p )
end
def Parser.parsers()
return @@parsers
end
end
class RSSParser < Parser
def get_type()
return "RSS"
end
def parse( xml )
# Parse the XML up and return some known format
return nil
end
end
Parser.add_parser( RSSParser )
class RDFParser < Parser
def get_type()
return "RDF"
end
def parse( xml )
# Parse the XML up and return some known format
return nil
end
end
Parser.add_parser( RDFParser )
SELECT TOP 10 FirstName, LastName, Email, --SUBSTRING(Phone, 2, 3) AS CityCode, SUBSTRING(Phone, 7, 8) AS PhoneNumber, upper(LanguagePref) AS Language, Address1, UpdatedOn AS CreatedOn FROM profiles WHERE -- Exclude all test emails Email NOT LIKE '%test%' AND Email NOT LIKE '%asdf%' ORDER BY UpdatedOn DESC
''
'' This is a VB test
''
'
' This is a VB test
'
Imports System.Collections
Dim stringWithUrl = "http://blog.dreamprojections.com"
Public Class MyVbClass
Private m_MyString As String
Public Sub New()
myString = "Hello there"
End Sub
Public Property MyString() As String
Get
Return m_MyString
End Get
Set(ByVal Value As String)
m_MyString = Value
End Set
End Property
#Region "This is my region"
' This is a comment
Public Function MyFunction( ByVal i as Integer ) As Double
MyFunction = 123.456
End Function
#End Region
End Class
<?xml version="1.0" encoding="utf-8" ?> <!-- comments --> <rootNode> <childNodes> <childNode attribute = "value" namespace:attribute='value' attribute=/> <childNode /> <childNode /> <childNode /> <childNode attribute="value"></childNode> <namespace:childNode> <![CDATA[ this is some CDATA content <!-- comments inside cdata --> <b alert='false'>tags inside cdata</b> ]]> </namespace:childNode> </childNodes> </rootNode> <!-- -- Multiline comments <b>tag</b> -->
echo 'hello world!';