Commit a1747745a4509d9b01ce60d91a043b410395de57

Golmote 2014-12-22T22:15:56

Add examples for Git, HTTP, LOLCODE, MATLAB, Perl, Python and Ruby

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
diff --git a/examples/prism-git.html b/examples/prism-git.html
new file mode 100644
index 0000000..c705c9d
--- /dev/null
+++ b/examples/prism-git.html
@@ -0,0 +1,13 @@
+<h1>Git</h1>
+<p>To use this language, use the class "language-git".</p>
+
+<h2>Comments</h2>
+<pre><code># On branch prism-examples
+# Changes to be committed:
+#   (use "git reset HEAD &lt;file>..." to unstage)
+#
+#       new file:   examples/prism-git.html</code></pre>
+
+<h2>Inserted and deleted lines</h2>
+<pre><code>- Some deleted line
++ Some added line</code></pre>
diff --git a/examples/prism-http.html b/examples/prism-http.html
new file mode 100644
index 0000000..3841979
--- /dev/null
+++ b/examples/prism-http.html
@@ -0,0 +1,36 @@
+<h1>HTTP</h1>
+<p>To use this language, use the class "language-http".</p>
+
+<h2>Request header</h2>
+<pre><code>GET http://localhost:9999/foo.html HTTP/1.1
+Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3
+Accept-Encoding: gzip, deflate</code></pre>
+
+<h2>Response header</h2>
+<pre><code>HTTP/1.1 200 OK
+Server: GitHub.com
+Date: Mon, 22 Dec 2014 18:25:30 GMT
+Content-Type: text/html; charset=utf-8</code></pre>
+
+<h2>Response body highlighted based on Content-Type</h2>
+<p>This currently supports the following content types :
+	"application/json",
+	"application/xml",
+	"text/xml" and
+	"text/html".</p>
+<pre><code>HTTP/1.1 200 OK
+Server: GitHub.com
+Date: Mon, 22 Dec 2014 18:25:30 GMT
+Content-Type: text/html; charset=utf-8
+Last-Modified: Sun, 21 Dec 2014 20:29:48 GMT
+Transfer-Encoding: chunked
+Expires: Mon, 22 Dec 2014 18:35:30 GMT
+Cache-Control: max-age=600
+Vary: Accept-Encoding
+Content-Encoding: gzip
+
+&lt;!DOCTYPE html>
+&lt;html lang="en">
+&lt;head>&lt;/head>
+&lt;body>&lt;/body>
+&lt;/html></code></pre>
\ No newline at end of file
diff --git a/examples/prism-jade.html b/examples/prism-jade.html
index 1b68125..4b7661f 100644
--- a/examples/prism-jade.html
+++ b/examples/prism-jade.html
@@ -27,7 +27,7 @@ div#foo(data-bar="foo")&attributes({'data-foo': 'bar'})</code></pre>
 <h2>Markup</h2>
 <pre><code>&lt;div class="foo bar">&lt;/div></code></pre>
 
-<h2>Flow control</h2>
+<h2>Control flow</h2>
 <pre><code>#user
   if user.description
     p.description= user.description
diff --git a/examples/prism-lolcode.html b/examples/prism-lolcode.html
new file mode 100644
index 0000000..b94ef5f
--- /dev/null
+++ b/examples/prism-lolcode.html
@@ -0,0 +1,65 @@
+<h1>LOLCODE</h1>
+<p>To use this language, use the class "language-lolcode".</p>
+
+<h2>Comments</h2>
+<pre><code>BTW Single line comment
+OBTW Multi-line
+comment TLDR</code></pre>
+
+<h2>Strings and special characters</h2>
+<pre><code>"foo :"bar:" baz"
+"foo:)bar:>baz"
+"Interpolation :{works} too!"</code></pre>
+
+<h2>Numbers</h2>
+<pre><code>42
+-42
+123.456</code></pre>
+
+<h2>Variable declaration</h2>
+<pre><code>I HAS A var
+var R "THREE"
+var R 3</code></pre>
+
+<h2>Types</h2>
+<pre><code>MAEK some_expr A YARN
+some_var IS NOW A NUMBR</code></pre>
+
+<h2>Full example</h2>
+<pre><code>OBTW Convert a number to hexadecimal. This
+     is returned as a string.
+TLDR
+HOW IZ I decimal_to_hex YR num
+    I HAS A i ITZ 0
+    I HAS A rem
+    I HAS A hex_num ITZ A BUKKIT
+    I HAS A decimal_num ITZ num
+    IM IN YR num_loop
+        rem R MOD OF decimal_num AN 16
+        I HAS A hex_digit
+        rem, WTF?
+            OMG 10, hex_digit R "A", GTFO
+            OMG 11, hex_digit R "B", GTFO
+            OMG 12, hex_digit R "C", GTFO
+            OMG 13, hex_digit R "D", GTFO
+            OMG 14, hex_digit R "E", GTFO
+            OMG 15, hex_digit R "F", GTFO
+            OMGWTF, hex_digit R rem
+        OIC
+        hex_num HAS A SRS i ITZ hex_digit
+        decimal_num R QUOSHUNT OF decimal_num AN 16
+        BOTH SAEM decimal_num AN 0, O RLY?
+            YA RLY, GTFO
+            NO WAI, i R SUM OF i AN 1
+        OIC
+    IM OUTTA YR num_loop
+    I HAS A hex_string ITZ A YARN
+    IM IN YR string_reverse
+        DIFFRINT i AN BIGGR OF i AN 0, O RLY?
+            YA RLY, GTFO
+        OIC
+        hex_string R SMOOSH hex_string AN hex_num'Z SRS i MKAY
+        i R DIFF OF i AN 1
+    IM OUTTA YR string_reverse
+    FOUND YR hex_string
+IF U SAY SOC</code></pre>
\ No newline at end of file
diff --git a/examples/prism-matlab.html b/examples/prism-matlab.html
new file mode 100644
index 0000000..00e985d
--- /dev/null
+++ b/examples/prism-matlab.html
@@ -0,0 +1,66 @@
+<h1>MATLAB</h1>
+<p>To use this language, use the class "language-matlab".</p>
+
+<h2>Strings</h2>
+<pre><code>myString = 'Hello, world';
+otherString = 'You''re right';</code></pre>
+
+<h2>Comments</h2>
+<pre><code>% Single line comment
+%{ Multi-line
+comment }%</code></pre>
+
+<h2>Numbers</h2>
+<pre><code>x = 325.499
+realmax + .0001e+308
+e = 1 - 3*(4/3 - 1)
+b = 1e-16 + 1 - 1e-16;
+x = 2 + 3i;
+z =
+   4.7842 -1.0921i   0.8648 -1.5931i   1.2616 -2.2753i
+   2.6130 -0.0941i   4.8987 -2.3898i   4.3787 -3.7538i
+   4.4007 -7.1512i   1.3572 -5.2915i   3.6865 -0.5182i
+</code></pre>
+
+<h2>Control flow</h2>
+<pre><code>if rem(a, 2) == 0
+    disp('a is even')
+    b = a/2;
+end
+switch dayString
+   case 'Monday'
+      disp('Start of the work week')
+   case 'Tuesday'
+      disp('Day 2')
+   case 'Wednesday'
+      disp('Day 3')
+   case 'Thursday'
+      disp('Day 4')
+   case 'Friday'
+      disp('Last day of the work week')
+   otherwise
+      disp('Weekend!')
+end
+n = 1;
+nFactorial = 1;
+while nFactorial < 1e100
+    n = n + 1;
+    nFactorial = nFactorial * n;
+end</code></pre>
+
+<h2>Functions</h2>
+<pre><code>q = integral(sqr,0,1);
+y = parabola(x)
+mygrid = @(x,y) ndgrid((-x:x/c:x),(-y:y/c:y));
+[x,y] = mygrid(pi,2*pi);</code></pre>
+
+<h2>Known failures</h2>
+<p>There are certain edge cases where Prism will fail.
+	There are always such cases in every regex-based syntax highlighter.
+	However, Prism dares to be open and honest about them.
+	If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs” list, just with a certain type of bug.
+</p>
+
+<h3>String inside comment</h3>
+<pre><code>%{ 'test' }%
+% 'test'</code></pre>
\ No newline at end of file
diff --git a/examples/prism-perl.html b/examples/prism-perl.html
new file mode 100644
index 0000000..f8c4802
--- /dev/null
+++ b/examples/prism-perl.html
@@ -0,0 +1,90 @@
+<h1>Perl</h1>
+<p>To use this language, use the class "language-perl".</p>
+
+<h2>Comments</h2>
+<pre><code># Single line comment
+=head1 Here There
+	Be Pods!
+=cut</code></pre>
+
+<h2>Strings</h2>
+<pre><code>q/foo bar baz/;
+q awhy not ?a;
+qw(foo bar baz) q{foo bar baz}
+q[foo bar baz] qq&lt;foo bar baz>
+"foo bar baz" 'foo bar baz' `foo bar baz`</code></pre>
+
+<h2>Regex</h2>
+<pre><code>m/foo/ s/foo/bar/
+m zfooz s zfoozbarz
+qr(foo) m{foo} s(foo)(bar) s{foo}{bar}
+m[foo] m&lt;foo> tr[foo][bar] s&lt;foo>&lt;bar>
+/foo/i
+</code></pre>
+
+<h2>Variables</h2>
+<pre><code>${^POSTMATCH}
+$^V
+$element_count = scalar(@whatever);
+keys(%users) = 1000;
+$1, $_, %!;</code></pre>
+
+<h2>Numbers</h2>
+<pre><code>12345
+12345.67
+.23E-10 # a very small number
+3.14_15_92 # a very important number
+4_294_967_296 # underscore for legibility
+0xff # hex
+0xdead_beef # more hex
+0377 # octal (only numbers, begins with 0)
+0b011011 # binary</code></pre>
+
+<h2>Full example</h2>
+<pre><code>sub read_config_file {
+  my ($class, $filename) = @_;
+
+  unless (defined $filename) {
+    my $home  = File::HomeDir->my_home || '.';
+    $filename = File::Spec->catfile($home, '.pause');
+
+    return {} unless -e $filename and -r _;
+  }
+
+  my %conf;
+  if ( eval { require Config::Identity } ) {
+    %conf = Config::Identity->load($filename);
+    $conf{user} = delete $conf{username} unless $conf{user};
+  }
+  else { # Process .pause manually
+    open my $pauserc, '<', $filename
+      or die "can't open $filename for reading: $!";
+
+    while (<$pauserc>) {
+      chomp;
+      next unless $_ and $_ !~ /^\s*#/;
+
+      my ($k, $v) = /^\s*(\w+)\s+(.+)$/;
+      Carp::croak "multiple enties for $k" if $conf{$k};
+      $conf{$k} = $v;
+    }
+  }
+
+  return \%conf;
+}</code></pre>
+
+<h2>Known failures</h2>
+<p>There are certain edge cases where Prism will fail.
+	There are always such cases in every regex-based syntax highlighter.
+	However, Prism dares to be open and honest about them.
+	If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs” list, just with a certain type of bug.
+</p>
+
+<h3>Comment-like substring</h3>
+<pre><code>"test # test";</code></pre>
+
+<h3>Comment symbol in regexp</h3>
+<pre><code>/test#test/;</code></pre>
+
+<h3>Two quotes of the same type (i.e. both single or both double) inside a regex</h3>
+<pre><code>/"foo"/;</code></pre>
\ No newline at end of file
diff --git a/examples/prism-python.html b/examples/prism-python.html
new file mode 100644
index 0000000..26cd46c
--- /dev/null
+++ b/examples/prism-python.html
@@ -0,0 +1,64 @@
+<h1>Python</h1>
+<p>To use this language, use the class "language-python".</p>
+
+<h2>Comments</h2>
+<pre><code># This is a comment
+# -*- coding: &lt;encoding-name> -*-</code></pre>
+
+<h2>Strings</h2>
+<pre><code>"foo \"bar\" baz"
+'foo \'bar\' baz'
+""" "Multi-line" strings
+are supported."""
+''' 'Multi-line' strings
+are supported.'''</code></pre>
+
+<h2>Numbers</h2>
+<pre><code>7
+2147483647
+0o177
+0b100110111
+3
+79228162514264337593543950336
+0o377
+0x100000000
+0xdeadbeef
+3.14
+10.
+.001
+1e100
+3.14e-10
+0e0
+3.14j
+10.j
+10j
+.001j
+1e100j
+3.14e-10j
+</code></pre>
+
+<h2>Full example</h2>
+<pre><code>def median(pool):
+    '''Statistical median to demonstrate doctest.
+    >>> median([2, 9, 9, 7, 9, 2, 4, 5, 8])
+    7
+    '''
+    copy = sorted(pool)
+    size = len(copy)
+    if size % 2 == 1:
+        return copy[(size - 1) / 2]
+    else:
+        return (copy[size/2 - 1] + copy[size/2]) / 2
+if __name__ == '__main__':
+    import doctest
+    doctest.testmod()</code></pre>
+
+<h2>Known failures</h2>
+<p>There are certain edge cases where Prism will fail.
+	There are always such cases in every regex-based syntax highlighter.
+	However, Prism dares to be open and honest about them.
+	If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs” list, just with a certain type of bug.
+</p>
+
+<h3>Comment-like substrings</h3>
+<pre><code>"foo # bar";</code></pre>
\ No newline at end of file
diff --git a/examples/prism-ruby.html b/examples/prism-ruby.html
new file mode 100644
index 0000000..8d724c9
--- /dev/null
+++ b/examples/prism-ruby.html
@@ -0,0 +1,46 @@
+<h1>Ruby</h1>
+<p>To use this language, use the class "language-ruby".</p>
+
+<h2>Single-line comments</h2>
+<pre><code># This is a comment</code></pre>
+
+<h2>Strings</h2>
+<pre><code>"foo \"bar\" baz"
+'foo \'bar\' baz'</code></pre>
+
+<h2>Regular expressions</h2>
+<pre><code>/foo?[ ]*bar/</code></pre>
+
+<h2>Variables</h2>
+<pre><code>$foo = 5;
+class InstTest
+  def set_foo(n)
+    @foo = n
+  end
+  def set_bar(n)
+    @bar = n
+  end
+end</code></pre>
+
+<h2>Symbols</h2>
+<pre><code>mystring = :steveT;</code></pre>
+
+<h2>Known failures</h2>
+<p>There are certain edge cases where Prism will fail.
+	There are always such cases in every regex-based syntax highlighter.
+	However, Prism dares to be open and honest about them.
+	If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs” list, just with a certain type of bug.
+</p>
+
+<h3>Comment-like substrings</h3>
+<pre><code>"foo # bar";</code></pre>
+
+<h3>Two quotes of the same type (i.e. both single or both double) inside a regex</h3>
+<pre><code>/"foo"/;</code></pre>
+
+<h3>Multi-line comments are not supported</h3>
+<pre><code>=begin
+************************
+This is a comment block
+************************
+=end</code></pre>
\ No newline at end of file