Add examples for ASP.NET, C, C++, Go, Scheme and Swift
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
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 %>
+<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>
\ 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 <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>
\ 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 <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>
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