-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
327 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<h1>ASP.NET (C#)</h1> | ||
<p>To use this language, use the class "language-aspnet".</p> | ||
|
||
<h2>Comments</h2> | ||
<pre><code><%-- This is a comment --%> | ||
<%-- This is a | ||
multi-line comment --%></code></pre> | ||
|
||
<h2>Page directives</h2> | ||
<pre><code><%@ Page Title="Products" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ProductList.aspx.cs" Inherits="WingtipToys.ProductList" %> | ||
</code></pre> | ||
|
||
<h2>Directive tag</h2> | ||
<pre><code><%: Page.Title %> | ||
<a href="ProductDetails.aspx?productID=<%#:Item.ProductID%>"> | ||
<span> | ||
<%#:Item.ProductName%> | ||
</span></code></pre> | ||
|
||
<h2>Highlighted C# inside scripts</h2> | ||
<p>This requires the C# component to be loaded. | ||
On this page, check C# <strong>before</strong> checking ASP.NET should make | ||
the example below work properly.</p> | ||
<pre><code><script runat="server"> | ||
// The following variables are visible to all procedures | ||
// within the script block. | ||
String str; | ||
int i; | ||
int i2; | ||
|
||
int DoubleIt(int inpt) | ||
{ | ||
// The following variable is visible only within | ||
// the DoubleIt procedure. | ||
int factor = 2; | ||
|
||
return inpt * factor; | ||
} | ||
</script></code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<h1>C</h1> | ||
<p>To use this language, use the class "language-c".</p> | ||
|
||
<h2>Strings</h2> | ||
<pre><code>"foo \"bar\" baz" | ||
'foo \'bar\' baz' | ||
"Multi-line strings ending with a \ | ||
are supported too."</code></pre> | ||
|
||
<h2>Macro statements</h2> | ||
<pre><code># include <stdio.h> | ||
#define PG_locked 0 | ||
#define PG_error 1 | ||
</code></pre> | ||
|
||
<h2>Full example</h2> | ||
<pre><code>#include <stdio.h> | ||
main(int argc, char *argv[]) | ||
{ | ||
int c; | ||
printf("Number of command line arguments passed: %d\n", argc); | ||
for ( c = 0 ; c < argc ; c++) | ||
printf("%d. Command line argument passed is %s\n", c+1, argv[c]); | ||
return 0; | ||
}</code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<h1>C++</h1> | ||
<p>To use this language, use the class "language-cpp".</p> | ||
|
||
<h2>Strings</h2> | ||
<pre><code>"foo \"bar\" baz" | ||
'foo \'bar\' baz' | ||
"Multi-line strings ending with a \ | ||
are supported too."</code></pre> | ||
|
||
<h2>Macro statements</h2> | ||
<pre><code># include <stdio.h> | ||
#define PG_locked 0 | ||
#define PG_error 1 | ||
</code></pre> | ||
|
||
<h2>Booleans</h2> | ||
<pre><code>true; | ||
false;</code></pre> | ||
|
||
<h2>Operators</h2> | ||
<pre><code>a and b; | ||
c bitand d;</code></pre> | ||
|
||
<h2>Full example</h2> | ||
<pre><code>/* | ||
David Cary 2010-09-14 | ||
quick demo for wikibooks | ||
public domain | ||
*/ | ||
#include <iostream> | ||
#include <vector> | ||
using namespace std; | ||
|
||
vector<int> pick_vector_with_biggest_fifth_element( | ||
vector<int> left, | ||
vector<int> right | ||
){ | ||
if( (left[5]) < (right[5]) ){ | ||
return( right ); | ||
}; | ||
// else | ||
return( left ); | ||
} | ||
|
||
int vector_demo(void){ | ||
cout << "vector demo" << endl; | ||
vector<int> left(7); | ||
vector<int> right(7); | ||
|
||
left[5] = 7; | ||
right[5] = 8; | ||
cout << left[5] << endl; | ||
cout << right[5] << endl; | ||
vector<int> biggest( | ||
pick_vector_with_biggest_fifth_element( left, right ) | ||
); | ||
cout << biggest[5] << endl; | ||
|
||
return 0; | ||
} | ||
|
||
int main(void){ | ||
vector_demo(); | ||
}</code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<h1>Go</h1> | ||
<p>To use this language, use the class "language-go".</p> | ||
|
||
<h2>Comments</h2> | ||
<pre><code>// This is a comment | ||
/* This is a comment | ||
on multiple lines */</code></pre> | ||
|
||
<h2>Numbers</h2> | ||
<pre><code>42 | ||
0600 | ||
0xBadFace | ||
170141183460469231731687303715884105727 | ||
0. | ||
72.40 | ||
072.40 | ||
2.71828 | ||
1.e+0 | ||
6.67428e-11 | ||
1E6 | ||
.25 | ||
.12345E+5 | ||
0i | ||
011i | ||
0.i | ||
2.71828i | ||
1.e+0i | ||
6.67428e-11i | ||
1E6i | ||
.25i | ||
.12345E+5i</code></pre> | ||
|
||
<h2>Runes and strings</h2> | ||
<pre><code>'\t' | ||
'\000' | ||
'\x07' | ||
'\u12e4' | ||
'\U00101234' | ||
`abc` | ||
`multi-line | ||
string` | ||
"Hello, world!" | ||
"multi-line | ||
string"</code></pre> | ||
|
||
<h2>Functions</h2> | ||
<pre><code>func(a, b int, z float64) bool { return a*b < int(z) }</code></pre> | ||
|
||
<h2>Full example</h2> | ||
<pre><code>package main | ||
import "fmt" | ||
|
||
func sum(a []int, c chan int) { | ||
sum := 0 | ||
for _, v := range a { | ||
sum += v | ||
} | ||
c <- sum // send sum to c | ||
} | ||
|
||
func main() { | ||
a := []int{7, 2, 8, -9, 4, 0} | ||
|
||
c := make(chan int) | ||
go sum(a[:len(a)/2], c) | ||
go sum(a[len(a)/2:], c) | ||
x, y := <-c, <-c // receive from c | ||
|
||
fmt.Println(x, y, x+y) | ||
} | ||
</code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<h1>Scheme</h1> | ||
<p>To use this language, use the class "language-scheme".</p> | ||
|
||
<h2>Comments</h2> | ||
<pre><code>; This is a comment</code></pre> | ||
|
||
<h2>Booleans</h2> | ||
<pre><code>#t | ||
#f</code></pre> | ||
|
||
<h2>Strings</h2> | ||
<pre><code>"two \"quotes\" within"</code></pre> | ||
|
||
<h2>Functions</h2> | ||
<pre><code>(lambda (x) (+ x 3)) | ||
(apply vector 'a 'b '(c d e)) | ||
</code></pre> | ||
|
||
<h2>Full example</h2> | ||
<pre><code>;; Calculation of Hofstadter's male and female sequences as a list of pairs | ||
|
||
(define (hofstadter-male-female n) | ||
(letrec ((female (lambda (n) | ||
(if (= n 0) | ||
1 | ||
(- n (male (female (- n 1))))))) | ||
(male (lambda (n) | ||
(if (= n 0) | ||
0 | ||
(- n (female (male (- n 1)))))))) | ||
(let loop ((i 0)) | ||
(if (> i n) | ||
'() | ||
(cons (cons (female i) | ||
(male i)) | ||
(loop (+ i 1))))))) | ||
|
||
(hofstadter-male-female 8)</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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<h1>Swift</h1> | ||
<p>To use this language, use the class "language-swift".</p> | ||
|
||
<h2>Comments</h2> | ||
<pre><code>// this is a comment | ||
/* this is also a comment, | ||
but written over multiple lines */ | ||
</code></pre> | ||
|
||
<h2>Numbers</h2> | ||
<pre><code>42 | ||
-23 | ||
3.14159 | ||
0.1 | ||
-273.15 | ||
1.25e-2 | ||
0xC.3p0 | ||
1_000_000 | ||
1_000_000.000_000_1</code></pre> | ||
|
||
<h2>Strings</h2> | ||
<pre><code>let someString = "Some string literal value" | ||
var emptyString = ""</code></pre> | ||
|
||
<h2>Control flow</h2> | ||
<pre><code>for index in 1...5 { | ||
println("\(index) times 5 is \(index * 5)") | ||
} | ||
for _ in 1...power { | ||
answer *= base | ||
} | ||
while square < finalSquare { | ||
// roll the dice | ||
if ++diceRoll == 7 { diceRoll = 1 } | ||
// move by the rolled amount | ||
square += diceRoll | ||
if square < board.count { | ||
// if we're still on the board, move up or down for a snake or a ladder | ||
square += board[square] | ||
} | ||
} | ||
switch someCharacter { | ||
case "a", "e", "i", "o", "u": | ||
println("\(someCharacter) is a vowel") | ||
case "b", "c", "d", "f", "g", "h", "j", "k", "l", "m", | ||
"n", "p", "q", "r", "s", "t", "v", "w", "x", "y", "z": | ||
println("\(someCharacter) is a consonant") | ||
default: | ||
println("\(someCharacter) is not a vowel or a consonant") | ||
} | ||
</code></pre> | ||
|
||
<h2>Classes and attributes</h2> | ||
<pre><code>class MyViewController: UIViewController { | ||
@IBOutlet weak var button: UIButton! | ||
@IBOutlet var textFields: [UITextField]! | ||
@IBAction func buttonTapped(AnyObject) { | ||
println("button tapped!") | ||
} | ||
} | ||
|
||
@IBDesignable | ||
class MyCustomView: UIView { | ||
@IBInspectable var textColor: UIColor | ||
@IBInspectable var iconHeight: CGFloat | ||
/* ... */ | ||
}</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>Nested block comments</h3> | ||
<pre><code>/* Nested block | ||
/* comments | ||
are */ | ||
not supported */</code></pre> |