Commit 68f60007c89e34659bb9fff48882791bcd076cc2

Golmote 2014-12-23T20:48:51

Add examples for ASP.NET, C, C++, Go, Scheme and Swift

diff --git a/examples/prism-aspnet.html b/examples/prism-aspnet.html
new file mode 100644
index 0000000..cdc1fc3
--- /dev/null
+++ b/examples/prism-aspnet.html
@@ -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 %>
+&lt;a href="ProductDetails.aspx?productID=<%#:Item.ProductID%>">
+&lt;span>
+    <%#:Item.ProductName%>
+&lt;/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>&lt;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;
+    }
+&lt;/script></code></pre>
\ No newline at end of file
diff --git a/examples/prism-c.html b/examples/prism-c.html
new file mode 100644
index 0000000..ae5e77d
--- /dev/null
+++ b/examples/prism-c.html
@@ -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 &lt;stdio.h>
+#define PG_locked   0
+#define PG_error    1
+</code></pre>
+
+<h2>Full example</h2>
+<pre><code>#include &lt;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>
\ No newline at end of file
diff --git a/examples/prism-cpp.html b/examples/prism-cpp.html
new file mode 100644
index 0000000..054f4af
--- /dev/null
+++ b/examples/prism-cpp.html
@@ -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 &lt;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 &lt;iostream>
+#include &lt;vector>
+using namespace std;
+
+vector&lt;int> pick_vector_with_biggest_fifth_element(
+    vector&lt;int> left,
+    vector&lt;int> right
+){
+    if( (left[5]) < (right[5]) ){
+        return( right );
+    };
+    // else
+    return( left );
+}
+
+int vector_demo(void){
+    cout << "vector demo" << endl;
+    vector&lt;int> left(7);
+    vector&lt;int> right(7);
+
+    left[5] = 7;
+    right[5] = 8;
+    cout << left[5] << endl;
+    cout << right[5] << endl;
+    vector&lt;int> biggest(
+        pick_vector_with_biggest_fifth_element( left, right )
+    );
+    cout << biggest[5] << endl;
+
+    return 0;
+}
+
+int main(void){
+    vector_demo();
+}</code></pre>
diff --git a/examples/prism-go.html b/examples/prism-go.html
new file mode 100644
index 0000000..196dcf4
--- /dev/null
+++ b/examples/prism-go.html
@@ -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>
\ No newline at end of file
diff --git a/examples/prism-scheme.html b/examples/prism-scheme.html
new file mode 100644
index 0000000..3b98271
--- /dev/null
+++ b/examples/prism-scheme.html
@@ -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>
\ No newline at end of file
diff --git a/examples/prism-swift.html b/examples/prism-swift.html
new file mode 100644
index 0000000..5bc1633
--- /dev/null
+++ b/examples/prism-swift.html
@@ -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>
\ No newline at end of file