Initial check-in
[dygraphs.git] / mochikit_v14 / examples / view-source / lib / SyntaxHighlighter / Tests.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
3 <html>
4 <head>
5 <title>dp.SyntaxHighlighter testing</title>
6 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
7
8 <link type="text/css" rel="stylesheet" href="SyntaxHighlighter.css"></link>
9
10 <style>
11 /* @import url(SyntaxHighlighter.css); */
12
13 body {
14 font-family: Arial;
15 font-size: 12px;
16 }
17 </style>
18 </head>
19
20 <body bgcolor="#cecece">
21
22 <h3>Smart Tabs &amp; First Line</h3>
23
24 <textarea name="code" class="c#:firstline[42]">
25 1 2 3 4 5 6 7 8 9
26 string path = "";
27 string safeReferrer = null;
28 FileInfo fileInfo = new FileInfo(string.Format("{0}/{1}", path, image));
29 int index = 0;
30 </textarea>
31
32 <h3>C Sharp</h3>
33
34 <textarea name="code" class="c#:collapse">
35 // single line comments
36 // second single line
37 override protected void OnLoad(EventArgs e)
38 {
39 if(Attributes["class"] != null)
40 {
41 //_year.CssClass = _month.CssClass = _day.CssClass = Attributes["class"];
42 }
43 // base.OnLoad(e);
44 }
45
46 /***********************************
47 ** Multiline block comments
48 **********************************/
49
50 /// <summary>
51 /// Gets or sets currently selected date of birth or <see cref="DateTime.MinValue"/> if selection is incomplete or invalid.
52 /// </summary>
53 public DateTime Date
54 {
55 String stringWithUrl = "http://blog.dreamprojections.com";
56
57 get
58 {
59 #region Hello world
60 try
61 {
62 /*
63 DateTime result = new DateTime(
64 int.Parse(_year.SelectedItem.Value),
65 int.Parse(_month.SelectedItem.Value),
66 int.Parse(_day.SelectedItem.Value)
67 );
68
69 i *= 2;
70 */
71 return result;
72 }
73 catch
74 {
75 /* return _minDate; */
76 }
77 #endregion
78 }
79 set
80 {
81 Day = value.Day;
82 Month = value.Month;
83 Year = value.Year;
84 }
85 }
86 </textarea>
87
88 <h3>JavaScript</h3>
89
90 <textarea name="code" class="javascript">
91 /***********************************
92 ** Multiline block comments
93 **********************************/
94
95 var stringWithUrl1 = "http://blog.dreamprojections.com";
96 var stringWithUrl2 = 'http://www.dreamprojections.com';
97
98 // callback for the match sorting
99 dpSyntaxHighlighter.prototype.SortCallback = function(m1, m2)
100 {
101 // sort matches by index first
102 if(m1.index < m2.index)
103 return -1;
104 else if(m1.index > m2.index)
105 return 1;
106 else
107 {
108 /*
109 // if index is the same, sort by length
110 if(m1.length < m2.length)
111 return -1;
112 else if(m1.length > m2.length)
113 return 1;
114 */
115 }
116
117 alert('hello // world');
118 return 0;
119 }
120 </textarea>
121
122 <h3>Visual Basic</h3>
123
124 <textarea name="code" class="vb">
125 '
126 ' This is a VB test
127 '
128
129 Imports System.Collections
130
131 Dim stringWithUrl = "http://blog.dreamprojections.com"
132
133 Public Class MyVbClass
134 Private m_MyString As String
135
136 Public Sub New()
137 myString = "Hello there"
138 End Sub
139
140 Public Property MyString() As String
141 Get
142 Return m_MyString
143 End Get
144 Set(ByVal Value As String)
145 m_MyString = Value
146 End Set
147 End Property
148
149 #Region "This is my region"
150 ' This is a comment
151 Public Function MyFunction( ByVal i as Integer ) As Double
152 MyFunction = 123.456
153 End Function
154 #End Region
155 End Class
156 </textarea>
157
158 <h3>XML / HTML</h3>
159
160 <textarea name="code" class="xml">
161 <?xml version="1.0" encoding="utf-8" ?>
162
163 <!-- comments -->
164 <rootNode>
165 <childNodes>
166 <childNode attribute = "value" attribute='value' attribute=/>
167 <childNode />
168 <childNode />
169 <childNode />
170 <childNode attribute="value"></childNode>
171 <childNode>
172 &lt;![CDATA[
173 this is some CDATA content
174 <!-- comments inside cdata -->
175 <b alert='false'>tags inside cdata</b>
176 ]]>
177 </childNode>
178 </childNodes>
179 </rootNode>
180
181 <!--
182 -- Multiline comments <b>tag</b>
183 -->
184 </textarea>
185
186 <h3>PHP</h3>
187
188 <textarea name="code" class="php">
189 /***********************************
190 ** Multiline block comments
191 **********************************/
192
193 $stringWithUrl = "http://blog.dreamprojections.com";
194 $stringWithUrl = 'http://www.dreamprojections.com';
195
196 ob_start("parseOutputBuffer"); // Start Code Buffering
197 session_start();
198
199 function parseOutputBuffer($buf) {
200 global $portal_small_code, $portal_gzcompress;
201 global $PHP_SELF, $HTTP_ACCEPT_ENCODING;
202
203 // cleaning out the code.
204 if($portal_small_code && !$portal_gzcompress) {
205 $buf = str_replace(" ", "", $buf);
206 $buf = str_replace("\n", "", $buf);
207 $buf = str_replace(chr(13), "", $buf);
208 }
209 }
210 </textarea>
211
212 <h3>SQL</h3>
213
214 <textarea name="code" class="sql">
215 SELECT TOP 10
216 FirstName,
217 LastName,
218 Email,
219 --SUBSTRING(Phone, 2, 3) AS CityCode,
220 SUBSTRING(Phone, 7, 8) AS PhoneNumber,
221 upper(LanguagePref) AS Language,
222 Address1,
223 UpdatedOn AS CreatedOn
224 FROM
225 profiles
226 WHERE
227 -- Exclude all test emails
228 Email NOT LIKE '%test%'
229 AND Email NOT LIKE '%asdf%'
230 ORDER BY
231 UpdatedOn DESC
232 </textarea>
233
234 <h3>Delphi</h3>
235
236 <textarea name="code" id="dd" class="delphi">
237 {$IFDEF VER140}
238 (***********************************
239 ** Multiline block comments
240 **********************************)
241 procedure TForm1.Button1Click(Sender: TObject); var
242 Number, I, X: Integer;
243 Y: Integer;
244 begin
245 str := 'http://blog.dreamprojections.com';
246
247 Number := 12356;
248 Caption := 'The Number is ' + IntToStr(Number);
249 for I := 0 to Number do
250 begin
251 Inc(X);
252 {
253 Dec(X);
254 X := X * 1.0;
255 }
256 Y := $F5D3;
257 ListBox1.Items.Add(IntToStr(X));
258
259 (*
260 ShowMessage('Hello'); *)
261 end;
262 asm
263 MOV AX,1234H
264 // MOV Number,AX
265 end;
266 end;
267 </textarea>
268
269 <h3>Python</h3>
270
271 <textarea name="code" class="python:nogutter:nocontrols">
272 cache = {}
273
274 string s = "## comments inside a string"
275
276 def arrange(plans, lines, totalMinutes):
277 """arrangements of plans taken lines times with an heuristic that the sum
278 of values in one arrangement is less then totalMinutes
279 """
280 #if in cache we are done otherwise start calculating and save them to cache
281 if (plans, lines, totalMinutes) in cache:
282 return cache[(plans, lines, totalMinutes)]
283 if lines==1:
284 r = [[plan] for plan in plans]
285 cache[(plans, lines, totalMinutes)] = r
286 return r
287 solutions = []
288 for plan in plans:
289 for ar in sort(list(arrange(plans, lines-1, totalMinutes))):
290 try:
291 one_solution = tuple(sort([plan] + list(ar)))
292 if sum(one_solution) <= totalMinutes and one_solution not in solutions:
293 solutions.append(one_solution)
294 except Exception, e:
295 print "Error:", str(e)
296 cache[(plans, lines, totalMinutes)] = solutions
297 return solutions
298
299 if __name__ == "__main__":
300 import sys
301 lines, totalMinutes = int(sys.argv[1]), int(sys.argv[2])
302 plans = tuple([int(p) for p in sys.argv[3:]])
303 print "for", lines, totalMinutes, plans
304 for sol in arrange(plans, lines, totalMinutes):
305 print sol
306 </textarea>
307
308 <h3>Auto Overflow Test</h3>
309
310 400px
311 <div style="width: 400px; border-top: 2px solid black;">
312
313 <textarea id="Textarea1" name="code" class="xml">
314 // this is a long line that will stretch the whole box causing it to scroll horizontally.
315 if($portal_small_code && !$portal_gzcompress) {
316 $buf = str_replace(" ", "", $buf);
317 $buf = str_replace("\n", "", $buf);
318 $buf = str_replace(chr(13), "", $buf);
319 }
320 </textarea>
321
322 </div>
323
324 </div>
325 <script class="javascript" src="shCore.js"></script>
326 <script class="javascript" src="shBrushCSharp.js"></script>
327 <script class="javascript" src="shBrushPhp.js"></script>
328 <script class="javascript" src="shBrushJScript.js"></script>
329 <script class="javascript" src="shBrushVb.js"></script>
330 <script class="javascript" src="shBrushSql.js"></script>
331 <script class="javascript" src="shBrushXml.js"></script>
332 <script class="javascript" src="shBrushDelphi.js"></script>
333 <script class="javascript" src="shBrushPython.js"></script>
334 <script class="javascript">
335 dp.SyntaxHighlighter.HighlightAll('code');
336 </script>
337
338 </body>
339 </html>