##// END OF EJS Templates
codecleaner
marcink -
r4029:c9bcfe2d default
parent child Browse files
Show More
@@ -1,61 +1,61 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: APL mode</title>
5 <title>CodeMirror: APL mode</title>
6 <link rel="stylesheet" href="../../doc/docs.css">
6 <link rel="stylesheet" href="../../doc/docs.css">
7 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <link rel="stylesheet" href="../../lib/codemirror.css">
8 <script src="../../lib/codemirror.js"></script>
8 <script src="../../lib/codemirror.js"></script>
9 <script src="../../addon/edit/matchbrackets.js"></script>
9 <script src="../../addon/edit/matchbrackets.js"></script>
10 <script src="apl.js"></script>
10 <script src="apl.js"></script>
11 <style>
11 <style>
12 .CodeMirror { border: 2px inset #dee; }
12 .CodeMirror { border: 2px inset #dee; }
13 </style>
13 </style>
14 </head>
14 </head>
15 <body>
15 <body>
16 <h1>CodeMirror: APL mode</h1>
16 <h1>CodeMirror: APL mode</h1>
17
17
18 <form><textarea id="code" name="code">
18 <form><textarea id="code" name="code">
19 ⍝ Conway's game of life
19 ⍝ Conway's game of life
20
20
21 ⍝ This example was inspired by the impressive demo at
21 ⍝ This example was inspired by the impressive demo at
22 ⍝ http://www.youtube.com/watch?v=a9xAKttWgP4
22 ⍝ http://www.youtube.com/watch?v=a9xAKttWgP4
23
23
24 ⍝ Create a matrix:
24 ⍝ Create a matrix:
25 ⍝ 0 1 1
25 ⍝ 0 1 1
26 ⍝ 1 1 0
26 ⍝ 1 1 0
27 ⍝ 0 1 0
27 ⍝ 0 1 0
28 creature ← (3 3 ⍴ ⍳ 9) ∈ 1 2 3 4 7 ⍝ Original creature from demo
28 creature ← (3 3 ⍴ ⍳ 9) ∈ 1 2 3 4 7 ⍝ Original creature from demo
29 creature ← (3 3 ⍴ ⍳ 9) ∈ 1 3 6 7 8 ⍝ Glider
29 creature ← (3 3 ⍴ ⍳ 9) ∈ 1 3 6 7 8 ⍝ Glider
30
30
31 ⍝ Place the creature on a larger board, near the centre
31 ⍝ Place the creature on a larger board, near the centre
32 board ← ¯1 ⊖ ¯2 ⌽ 5 7 ↑ creature
32 board ← ¯1 ⊖ ¯2 ⌽ 5 7 ↑ creature
33
33
34 ⍝ A function to move from one generation to the next
34 ⍝ A function to move from one generation to the next
35 life ← {∨/ 1 ⍵ ∧ 3 4 = ⊂+/ +⌿ 1 0 ¯1 ∘.⊖ 1 0 ¯1 ⌽¨ ⊂⍵}
35 life ← {∨/ 1 ⍵ ∧ 3 4 = ⊂+/ +⌿ 1 0 ¯1 ∘.⊖ 1 0 ¯1 ⌽¨ ⊂⍵}
36
36
37 ⍝ Compute n-th generation and format it as a
37 ⍝ Compute n-th generation and format it as a
38 ⍝ character matrix
38 ⍝ character matrix
39 gen ← {' #'[(life ⍣ ⍵) board]}
39 gen ← {' #'[(life ⍣ ⍵) board]}
40
40
41 ⍝ Show first three generations
41 ⍝ Show first three generations
42 (gen 1) (gen 2) (gen 3)
42 (gen 1) (gen 2) (gen 3)
43 </textarea></form>
43 </textarea></form>
44
44
45 <script>
45 <script>
46 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
46 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
47 lineNumbers: true,
47 lineNumbers: true,
48 matchBrackets: true,
48 matchBrackets: true,
49 mode: "text/apl"
49 mode: "text/apl"
50 });
50 });
51 </script>
51 </script>
52
52
53 <p>Simple mode that tries to handle APL as well as it can.</p>
53 <p>Simple mode that tries to handle APL as well as it can.</p>
54 <p>It attempts to label functions/operators based upon
54 <p>It attempts to label functions/operators based upon
55 monadic/dyadic usage (but this is far from fully fleshed out).
55 monadic/dyadic usage (but this is far from fully fleshed out).
56 This means there are meaningful classnames so hover states can
56 This means there are meaningful classnames so hover states can
57 have popups etc.</p>
57 have popups etc.</p>
58
58
59 <p><strong>MIME types defined:</strong> <code>text/apl</code> (APL code)</p>
59 <p><strong>MIME types defined:</strong> <code>text/apl</code> (APL code)</p>
60 </body>
60 </body>
61 </html>
61 </html>
@@ -1,142 +1,142 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: Asterisk dialplan mode</title>
5 <title>CodeMirror: Asterisk dialplan mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="asterisk.js"></script>
8 <script src="asterisk.js"></script>
9 <style>
9 <style>
10 .CodeMirror {border: 1px solid #999;}
10 .CodeMirror {border: 1px solid #999;}
11 .cm-s-default span.cm-arrow { color: red; }
11 .cm-s-default span.cm-arrow { color: red; }
12 </style>
12 </style>
13 <link rel="stylesheet" href="../../doc/docs.css">
13 <link rel="stylesheet" href="../../doc/docs.css">
14 </head>
14 </head>
15 <body>
15 <body>
16 <h1>CodeMirror: Asterisk dialplan mode</h1>
16 <h1>CodeMirror: Asterisk dialplan mode</h1>
17 <form><textarea id="code" name="code">
17 <form><textarea id="code" name="code">
18 ; extensions.conf - the Asterisk dial plan
18 ; extensions.conf - the Asterisk dial plan
19 ;
19 ;
20
20
21 [general]
21 [general]
22 ;
22 ;
23 ; If static is set to no, or omitted, then the pbx_config will rewrite
23 ; If static is set to no, or omitted, then the pbx_config will rewrite
24 ; this file when extensions are modified. Remember that all comments
24 ; this file when extensions are modified. Remember that all comments
25 ; made in the file will be lost when that happens.
25 ; made in the file will be lost when that happens.
26 static=yes
26 static=yes
27
27
28 #include "/etc/asterisk/additional_general.conf
28 #include "/etc/asterisk/additional_general.conf
29
29
30 [iaxprovider]
30 [iaxprovider]
31 switch => IAX2/user:[key]@myserver/mycontext
31 switch => IAX2/user:[key]@myserver/mycontext
32
32
33 [dynamic]
33 [dynamic]
34 #exec /usr/bin/dynamic-peers.pl
34 #exec /usr/bin/dynamic-peers.pl
35
35
36 [trunkint]
36 [trunkint]
37 ;
37 ;
38 ; International long distance through trunk
38 ; International long distance through trunk
39 ;
39 ;
40 exten => _9011.,1,Macro(dundi-e164,${EXTEN:4})
40 exten => _9011.,1,Macro(dundi-e164,${EXTEN:4})
41 exten => _9011.,n,Dial(${GLOBAL(TRUNK)}/${FILTER(0-9,${EXTEN:${GLOBAL(TRUNKMSD)}})})
41 exten => _9011.,n,Dial(${GLOBAL(TRUNK)}/${FILTER(0-9,${EXTEN:${GLOBAL(TRUNKMSD)}})})
42
42
43 [local]
43 [local]
44 ;
44 ;
45 ; Master context for local, toll-free, and iaxtel calls only
45 ; Master context for local, toll-free, and iaxtel calls only
46 ;
46 ;
47 ignorepat => 9
47 ignorepat => 9
48 include => default
48 include => default
49
49
50 [demo]
50 [demo]
51 include => stdexten
51 include => stdexten
52 ;
52 ;
53 ; We start with what to do when a call first comes in.
53 ; We start with what to do when a call first comes in.
54 ;
54 ;
55 exten => s,1,Wait(1) ; Wait a second, just for fun
55 exten => s,1,Wait(1) ; Wait a second, just for fun
56 same => n,Answer ; Answer the line
56 same => n,Answer ; Answer the line
57 same => n,Set(TIMEOUT(digit)=5) ; Set Digit Timeout to 5 seconds
57 same => n,Set(TIMEOUT(digit)=5) ; Set Digit Timeout to 5 seconds
58 same => n,Set(TIMEOUT(response)=10) ; Set Response Timeout to 10 seconds
58 same => n,Set(TIMEOUT(response)=10) ; Set Response Timeout to 10 seconds
59 same => n(restart),BackGround(demo-congrats) ; Play a congratulatory message
59 same => n(restart),BackGround(demo-congrats) ; Play a congratulatory message
60 same => n(instruct),BackGround(demo-instruct) ; Play some instructions
60 same => n(instruct),BackGround(demo-instruct) ; Play some instructions
61 same => n,WaitExten ; Wait for an extension to be dialed.
61 same => n,WaitExten ; Wait for an extension to be dialed.
62
62
63 exten => 2,1,BackGround(demo-moreinfo) ; Give some more information.
63 exten => 2,1,BackGround(demo-moreinfo) ; Give some more information.
64 exten => 2,n,Goto(s,instruct)
64 exten => 2,n,Goto(s,instruct)
65
65
66 exten => 3,1,Set(LANGUAGE()=fr) ; Set language to french
66 exten => 3,1,Set(LANGUAGE()=fr) ; Set language to french
67 exten => 3,n,Goto(s,restart) ; Start with the congratulations
67 exten => 3,n,Goto(s,restart) ; Start with the congratulations
68
68
69 exten => 1000,1,Goto(default,s,1)
69 exten => 1000,1,Goto(default,s,1)
70 ;
70 ;
71 ; We also create an example user, 1234, who is on the console and has
71 ; We also create an example user, 1234, who is on the console and has
72 ; voicemail, etc.
72 ; voicemail, etc.
73 ;
73 ;
74 exten => 1234,1,Playback(transfer,skip) ; "Please hold while..."
74 exten => 1234,1,Playback(transfer,skip) ; "Please hold while..."
75 ; (but skip if channel is not up)
75 ; (but skip if channel is not up)
76 exten => 1234,n,Gosub(${EXTEN},stdexten(${GLOBAL(CONSOLE)}))
76 exten => 1234,n,Gosub(${EXTEN},stdexten(${GLOBAL(CONSOLE)}))
77 exten => 1234,n,Goto(default,s,1) ; exited Voicemail
77 exten => 1234,n,Goto(default,s,1) ; exited Voicemail
78
78
79 exten => 1235,1,Voicemail(1234,u) ; Right to voicemail
79 exten => 1235,1,Voicemail(1234,u) ; Right to voicemail
80
80
81 exten => 1236,1,Dial(Console/dsp) ; Ring forever
81 exten => 1236,1,Dial(Console/dsp) ; Ring forever
82 exten => 1236,n,Voicemail(1234,b) ; Unless busy
82 exten => 1236,n,Voicemail(1234,b) ; Unless busy
83
83
84 ;
84 ;
85 ; # for when they're done with the demo
85 ; # for when they're done with the demo
86 ;
86 ;
87 exten => #,1,Playback(demo-thanks) ; "Thanks for trying the demo"
87 exten => #,1,Playback(demo-thanks) ; "Thanks for trying the demo"
88 exten => #,n,Hangup ; Hang them up.
88 exten => #,n,Hangup ; Hang them up.
89
89
90 ;
90 ;
91 ; A timeout and "invalid extension rule"
91 ; A timeout and "invalid extension rule"
92 ;
92 ;
93 exten => t,1,Goto(#,1) ; If they take too long, give up
93 exten => t,1,Goto(#,1) ; If they take too long, give up
94 exten => i,1,Playback(invalid) ; "That's not valid, try again"
94 exten => i,1,Playback(invalid) ; "That's not valid, try again"
95
95
96 ;
96 ;
97 ; Create an extension, 500, for dialing the
97 ; Create an extension, 500, for dialing the
98 ; Asterisk demo.
98 ; Asterisk demo.
99 ;
99 ;
100 exten => 500,1,Playback(demo-abouttotry); Let them know what's going on
100 exten => 500,1,Playback(demo-abouttotry); Let them know what's going on
101 exten => 500,n,Dial(IAX2/guest@pbx.digium.com/s@default) ; Call the Asterisk demo
101 exten => 500,n,Dial(IAX2/guest@pbx.digium.com/s@default) ; Call the Asterisk demo
102 exten => 500,n,Playback(demo-nogo) ; Couldn't connect to the demo site
102 exten => 500,n,Playback(demo-nogo) ; Couldn't connect to the demo site
103 exten => 500,n,Goto(s,6) ; Return to the start over message.
103 exten => 500,n,Goto(s,6) ; Return to the start over message.
104
104
105 ;
105 ;
106 ; Create an extension, 600, for evaluating echo latency.
106 ; Create an extension, 600, for evaluating echo latency.
107 ;
107 ;
108 exten => 600,1,Playback(demo-echotest) ; Let them know what's going on
108 exten => 600,1,Playback(demo-echotest) ; Let them know what's going on
109 exten => 600,n,Echo ; Do the echo test
109 exten => 600,n,Echo ; Do the echo test
110 exten => 600,n,Playback(demo-echodone) ; Let them know it's over
110 exten => 600,n,Playback(demo-echodone) ; Let them know it's over
111 exten => 600,n,Goto(s,6) ; Start over
111 exten => 600,n,Goto(s,6) ; Start over
112
112
113 ;
113 ;
114 ; You can use the Macro Page to intercom a individual user
114 ; You can use the Macro Page to intercom a individual user
115 exten => 76245,1,Macro(page,SIP/Grandstream1)
115 exten => 76245,1,Macro(page,SIP/Grandstream1)
116 ; or if your peernames are the same as extensions
116 ; or if your peernames are the same as extensions
117 exten => _7XXX,1,Macro(page,SIP/${EXTEN})
117 exten => _7XXX,1,Macro(page,SIP/${EXTEN})
118 ;
118 ;
119 ;
119 ;
120 ; System Wide Page at extension 7999
120 ; System Wide Page at extension 7999
121 ;
121 ;
122 exten => 7999,1,Set(TIMEOUT(absolute)=60)
122 exten => 7999,1,Set(TIMEOUT(absolute)=60)
123 exten => 7999,2,Page(Local/Grandstream1@page&Local/Xlite1@page&Local/1234@page/n,d)
123 exten => 7999,2,Page(Local/Grandstream1@page&Local/Xlite1@page&Local/1234@page/n,d)
124
124
125 ; Give voicemail at extension 8500
125 ; Give voicemail at extension 8500
126 ;
126 ;
127 exten => 8500,1,VoicemailMain
127 exten => 8500,1,VoicemailMain
128 exten => 8500,n,Goto(s,6)
128 exten => 8500,n,Goto(s,6)
129
129
130 </textarea></form>
130 </textarea></form>
131 <script>
131 <script>
132 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
132 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
133 mode: "text/x-asterisk",
133 mode: "text/x-asterisk",
134 matchBrackets: true,
134 matchBrackets: true,
135 lineNumber: true
135 lineNumber: true
136 });
136 });
137 </script>
137 </script>
138
138
139 <p><strong>MIME types defined:</strong> <code>text/x-asterisk</code>.</p>
139 <p><strong>MIME types defined:</strong> <code>text/x-asterisk</code>.</p>
140
140
141 </body>
141 </body>
142 </html>
142 </html>
@@ -1,767 +1,767 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: C-like mode</title>
5 <title>CodeMirror: C-like mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <link rel="stylesheet" href="../../theme/ambiance.css">
7 <link rel="stylesheet" href="../../theme/ambiance.css">
8 <script src="../../lib/codemirror.js"></script>
8 <script src="../../lib/codemirror.js"></script>
9 <script src="../../addon/edit/matchbrackets.js"></script>
9 <script src="../../addon/edit/matchbrackets.js"></script>
10 <script src="clike.js"></script>
10 <script src="clike.js"></script>
11 <link rel="stylesheet" href="../../doc/docs.css">
11 <link rel="stylesheet" href="../../doc/docs.css">
12 <style>
12 <style>
13 body
13 body
14 {
14 {
15 margin: 0;
15 margin: 0;
16 padding: 0;
16 padding: 0;
17 max-width:inherit;
17 max-width:inherit;
18 height: 100%;
18 height: 100%;
19 }
19 }
20 html, form, .CodeMirror, .CodeMirror-scroll
20 html, form, .CodeMirror, .CodeMirror-scroll
21 {
21 {
22 height: 100%;
22 height: 100%;
23 }
23 }
24 </style>
24 </style>
25 </head>
25 </head>
26 <body>
26 <body>
27 <form>
27 <form>
28 <textarea id="code" name="code">
28 <textarea id="code" name="code">
29
29
30 /* __ *\
30 /* __ *\
31 ** ________ ___ / / ___ Scala API **
31 ** ________ ___ / / ___ Scala API **
32 ** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL **
32 ** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL **
33 ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
33 ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
34 ** /____/\___/_/ |_/____/_/ | | **
34 ** /____/\___/_/ |_/____/_/ | | **
35 ** |/ **
35 ** |/ **
36 \* */
36 \* */
37
37
38 package scala.collection
38 package scala.collection
39
39
40 import generic._
40 import generic._
41 import mutable.{ Builder, ListBuffer }
41 import mutable.{ Builder, ListBuffer }
42 import annotation.{tailrec, migration, bridge}
42 import annotation.{tailrec, migration, bridge}
43 import annotation.unchecked.{ uncheckedVariance => uV }
43 import annotation.unchecked.{ uncheckedVariance => uV }
44 import parallel.ParIterable
44 import parallel.ParIterable
45
45
46 /** A template trait for traversable collections of type `Traversable[A]`.
46 /** A template trait for traversable collections of type `Traversable[A]`.
47 *
47 *
48 * $traversableInfo
48 * $traversableInfo
49 * @define mutability
49 * @define mutability
50 * @define traversableInfo
50 * @define traversableInfo
51 * This is a base trait of all kinds of $mutability Scala collections. It
51 * This is a base trait of all kinds of $mutability Scala collections. It
52 * implements the behavior common to all collections, in terms of a method
52 * implements the behavior common to all collections, in terms of a method
53 * `foreach` with signature:
53 * `foreach` with signature:
54 * {{{
54 * {{{
55 * def foreach[U](f: Elem => U): Unit
55 * def foreach[U](f: Elem => U): Unit
56 * }}}
56 * }}}
57 * Collection classes mixing in this trait provide a concrete
57 * Collection classes mixing in this trait provide a concrete
58 * `foreach` method which traverses all the
58 * `foreach` method which traverses all the
59 * elements contained in the collection, applying a given function to each.
59 * elements contained in the collection, applying a given function to each.
60 * They also need to provide a method `newBuilder`
60 * They also need to provide a method `newBuilder`
61 * which creates a builder for collections of the same kind.
61 * which creates a builder for collections of the same kind.
62 *
62 *
63 * A traversable class might or might not have two properties: strictness
63 * A traversable class might or might not have two properties: strictness
64 * and orderedness. Neither is represented as a type.
64 * and orderedness. Neither is represented as a type.
65 *
65 *
66 * The instances of a strict collection class have all their elements
66 * The instances of a strict collection class have all their elements
67 * computed before they can be used as values. By contrast, instances of
67 * computed before they can be used as values. By contrast, instances of
68 * a non-strict collection class may defer computation of some of their
68 * a non-strict collection class may defer computation of some of their
69 * elements until after the instance is available as a value.
69 * elements until after the instance is available as a value.
70 * A typical example of a non-strict collection class is a
70 * A typical example of a non-strict collection class is a
71 * <a href="../immutable/Stream.html" target="ContentFrame">
71 * <a href="../immutable/Stream.html" target="ContentFrame">
72 * `scala.collection.immutable.Stream`</a>.
72 * `scala.collection.immutable.Stream`</a>.
73 * A more general class of examples are `TraversableViews`.
73 * A more general class of examples are `TraversableViews`.
74 *
74 *
75 * If a collection is an instance of an ordered collection class, traversing
75 * If a collection is an instance of an ordered collection class, traversing
76 * its elements with `foreach` will always visit elements in the
76 * its elements with `foreach` will always visit elements in the
77 * same order, even for different runs of the program. If the class is not
77 * same order, even for different runs of the program. If the class is not
78 * ordered, `foreach` can visit elements in different orders for
78 * ordered, `foreach` can visit elements in different orders for
79 * different runs (but it will keep the same order in the same run).'
79 * different runs (but it will keep the same order in the same run).'
80 *
80 *
81 * A typical example of a collection class which is not ordered is a
81 * A typical example of a collection class which is not ordered is a
82 * `HashMap` of objects. The traversal order for hash maps will
82 * `HashMap` of objects. The traversal order for hash maps will
83 * depend on the hash codes of its elements, and these hash codes might
83 * depend on the hash codes of its elements, and these hash codes might
84 * differ from one run to the next. By contrast, a `LinkedHashMap`
84 * differ from one run to the next. By contrast, a `LinkedHashMap`
85 * is ordered because it's `foreach` method visits elements in the
85 * is ordered because it's `foreach` method visits elements in the
86 * order they were inserted into the `HashMap`.
86 * order they were inserted into the `HashMap`.
87 *
87 *
88 * @author Martin Odersky
88 * @author Martin Odersky
89 * @version 2.8
89 * @version 2.8
90 * @since 2.8
90 * @since 2.8
91 * @tparam A the element type of the collection
91 * @tparam A the element type of the collection
92 * @tparam Repr the type of the actual collection containing the elements.
92 * @tparam Repr the type of the actual collection containing the elements.
93 *
93 *
94 * @define Coll Traversable
94 * @define Coll Traversable
95 * @define coll traversable collection
95 * @define coll traversable collection
96 */
96 */
97 trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr]
97 trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr]
98 with FilterMonadic[A, Repr]
98 with FilterMonadic[A, Repr]
99 with TraversableOnce[A]
99 with TraversableOnce[A]
100 with GenTraversableLike[A, Repr]
100 with GenTraversableLike[A, Repr]
101 with Parallelizable[A, ParIterable[A]]
101 with Parallelizable[A, ParIterable[A]]
102 {
102 {
103 self =>
103 self =>
104
104
105 import Traversable.breaks._
105 import Traversable.breaks._
106
106
107 /** The type implementing this traversable */
107 /** The type implementing this traversable */
108 protected type Self = Repr
108 protected type Self = Repr
109
109
110 /** The collection of type $coll underlying this `TraversableLike` object.
110 /** The collection of type $coll underlying this `TraversableLike` object.
111 * By default this is implemented as the `TraversableLike` object itself,
111 * By default this is implemented as the `TraversableLike` object itself,
112 * but this can be overridden.
112 * but this can be overridden.
113 */
113 */
114 def repr: Repr = this.asInstanceOf[Repr]
114 def repr: Repr = this.asInstanceOf[Repr]
115
115
116 /** The underlying collection seen as an instance of `$Coll`.
116 /** The underlying collection seen as an instance of `$Coll`.
117 * By default this is implemented as the current collection object itself,
117 * By default this is implemented as the current collection object itself,
118 * but this can be overridden.
118 * but this can be overridden.
119 */
119 */
120 protected[this] def thisCollection: Traversable[A] = this.asInstanceOf[Traversable[A]]
120 protected[this] def thisCollection: Traversable[A] = this.asInstanceOf[Traversable[A]]
121
121
122 /** A conversion from collections of type `Repr` to `$Coll` objects.
122 /** A conversion from collections of type `Repr` to `$Coll` objects.
123 * By default this is implemented as just a cast, but this can be overridden.
123 * By default this is implemented as just a cast, but this can be overridden.
124 */
124 */
125 protected[this] def toCollection(repr: Repr): Traversable[A] = repr.asInstanceOf[Traversable[A]]
125 protected[this] def toCollection(repr: Repr): Traversable[A] = repr.asInstanceOf[Traversable[A]]
126
126
127 /** Creates a new builder for this collection type.
127 /** Creates a new builder for this collection type.
128 */
128 */
129 protected[this] def newBuilder: Builder[A, Repr]
129 protected[this] def newBuilder: Builder[A, Repr]
130
130
131 protected[this] def parCombiner = ParIterable.newCombiner[A]
131 protected[this] def parCombiner = ParIterable.newCombiner[A]
132
132
133 /** Applies a function `f` to all elements of this $coll.
133 /** Applies a function `f` to all elements of this $coll.
134 *
134 *
135 * Note: this method underlies the implementation of most other bulk operations.
135 * Note: this method underlies the implementation of most other bulk operations.
136 * It's important to implement this method in an efficient way.
136 * It's important to implement this method in an efficient way.
137 *
137 *
138 *
138 *
139 * @param f the function that is applied for its side-effect to every element.
139 * @param f the function that is applied for its side-effect to every element.
140 * The result of function `f` is discarded.
140 * The result of function `f` is discarded.
141 *
141 *
142 * @tparam U the type parameter describing the result of function `f`.
142 * @tparam U the type parameter describing the result of function `f`.
143 * This result will always be ignored. Typically `U` is `Unit`,
143 * This result will always be ignored. Typically `U` is `Unit`,
144 * but this is not necessary.
144 * but this is not necessary.
145 *
145 *
146 * @usecase def foreach(f: A => Unit): Unit
146 * @usecase def foreach(f: A => Unit): Unit
147 */
147 */
148 def foreach[U](f: A => U): Unit
148 def foreach[U](f: A => U): Unit
149
149
150 /** Tests whether this $coll is empty.
150 /** Tests whether this $coll is empty.
151 *
151 *
152 * @return `true` if the $coll contain no elements, `false` otherwise.
152 * @return `true` if the $coll contain no elements, `false` otherwise.
153 */
153 */
154 def isEmpty: Boolean = {
154 def isEmpty: Boolean = {
155 var result = true
155 var result = true
156 breakable {
156 breakable {
157 for (x <- this) {
157 for (x <- this) {
158 result = false
158 result = false
159 break
159 break
160 }
160 }
161 }
161 }
162 result
162 result
163 }
163 }
164
164
165 /** Tests whether this $coll is known to have a finite size.
165 /** Tests whether this $coll is known to have a finite size.
166 * All strict collections are known to have finite size. For a non-strict collection
166 * All strict collections are known to have finite size. For a non-strict collection
167 * such as `Stream`, the predicate returns `true` if all elements have been computed.
167 * such as `Stream`, the predicate returns `true` if all elements have been computed.
168 * It returns `false` if the stream is not yet evaluated to the end.
168 * It returns `false` if the stream is not yet evaluated to the end.
169 *
169 *
170 * Note: many collection methods will not work on collections of infinite sizes.
170 * Note: many collection methods will not work on collections of infinite sizes.
171 *
171 *
172 * @return `true` if this collection is known to have finite size, `false` otherwise.
172 * @return `true` if this collection is known to have finite size, `false` otherwise.
173 */
173 */
174 def hasDefiniteSize = true
174 def hasDefiniteSize = true
175
175
176 def ++[B >: A, That](that: GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
176 def ++[B >: A, That](that: GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
177 val b = bf(repr)
177 val b = bf(repr)
178 if (that.isInstanceOf[IndexedSeqLike[_, _]]) b.sizeHint(this, that.seq.size)
178 if (that.isInstanceOf[IndexedSeqLike[_, _]]) b.sizeHint(this, that.seq.size)
179 b ++= thisCollection
179 b ++= thisCollection
180 b ++= that.seq
180 b ++= that.seq
181 b.result
181 b.result
182 }
182 }
183
183
184 @bridge
184 @bridge
185 def ++[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That =
185 def ++[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That =
186 ++(that: GenTraversableOnce[B])(bf)
186 ++(that: GenTraversableOnce[B])(bf)
187
187
188 /** Concatenates this $coll with the elements of a traversable collection.
188 /** Concatenates this $coll with the elements of a traversable collection.
189 * It differs from ++ in that the right operand determines the type of the
189 * It differs from ++ in that the right operand determines the type of the
190 * resulting collection rather than the left one.
190 * resulting collection rather than the left one.
191 *
191 *
192 * @param that the traversable to append.
192 * @param that the traversable to append.
193 * @tparam B the element type of the returned collection.
193 * @tparam B the element type of the returned collection.
194 * @tparam That $thatinfo
194 * @tparam That $thatinfo
195 * @param bf $bfinfo
195 * @param bf $bfinfo
196 * @return a new collection of type `That` which contains all elements
196 * @return a new collection of type `That` which contains all elements
197 * of this $coll followed by all elements of `that`.
197 * of this $coll followed by all elements of `that`.
198 *
198 *
199 * @usecase def ++:[B](that: TraversableOnce[B]): $Coll[B]
199 * @usecase def ++:[B](that: TraversableOnce[B]): $Coll[B]
200 *
200 *
201 * @return a new $coll which contains all elements of this $coll
201 * @return a new $coll which contains all elements of this $coll
202 * followed by all elements of `that`.
202 * followed by all elements of `that`.
203 */
203 */
204 def ++:[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
204 def ++:[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
205 val b = bf(repr)
205 val b = bf(repr)
206 if (that.isInstanceOf[IndexedSeqLike[_, _]]) b.sizeHint(this, that.size)
206 if (that.isInstanceOf[IndexedSeqLike[_, _]]) b.sizeHint(this, that.size)
207 b ++= that
207 b ++= that
208 b ++= thisCollection
208 b ++= thisCollection
209 b.result
209 b.result
210 }
210 }
211
211
212 /** This overload exists because: for the implementation of ++: we should reuse
212 /** This overload exists because: for the implementation of ++: we should reuse
213 * that of ++ because many collections override it with more efficient versions.
213 * that of ++ because many collections override it with more efficient versions.
214 * Since TraversableOnce has no '++' method, we have to implement that directly,
214 * Since TraversableOnce has no '++' method, we have to implement that directly,
215 * but Traversable and down can use the overload.
215 * but Traversable and down can use the overload.
216 */
216 */
217 def ++:[B >: A, That](that: Traversable[B])(implicit bf: CanBuildFrom[Repr, B, That]): That =
217 def ++:[B >: A, That](that: Traversable[B])(implicit bf: CanBuildFrom[Repr, B, That]): That =
218 (that ++ seq)(breakOut)
218 (that ++ seq)(breakOut)
219
219
220 def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
220 def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
221 val b = bf(repr)
221 val b = bf(repr)
222 b.sizeHint(this)
222 b.sizeHint(this)
223 for (x <- this) b += f(x)
223 for (x <- this) b += f(x)
224 b.result
224 b.result
225 }
225 }
226
226
227 def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
227 def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
228 val b = bf(repr)
228 val b = bf(repr)
229 for (x <- this) b ++= f(x).seq
229 for (x <- this) b ++= f(x).seq
230 b.result
230 b.result
231 }
231 }
232
232
233 /** Selects all elements of this $coll which satisfy a predicate.
233 /** Selects all elements of this $coll which satisfy a predicate.
234 *
234 *
235 * @param p the predicate used to test elements.
235 * @param p the predicate used to test elements.
236 * @return a new $coll consisting of all elements of this $coll that satisfy the given
236 * @return a new $coll consisting of all elements of this $coll that satisfy the given
237 * predicate `p`. The order of the elements is preserved.
237 * predicate `p`. The order of the elements is preserved.
238 */
238 */
239 def filter(p: A => Boolean): Repr = {
239 def filter(p: A => Boolean): Repr = {
240 val b = newBuilder
240 val b = newBuilder
241 for (x <- this)
241 for (x <- this)
242 if (p(x)) b += x
242 if (p(x)) b += x
243 b.result
243 b.result
244 }
244 }
245
245
246 /** Selects all elements of this $coll which do not satisfy a predicate.
246 /** Selects all elements of this $coll which do not satisfy a predicate.
247 *
247 *
248 * @param p the predicate used to test elements.
248 * @param p the predicate used to test elements.
249 * @return a new $coll consisting of all elements of this $coll that do not satisfy the given
249 * @return a new $coll consisting of all elements of this $coll that do not satisfy the given
250 * predicate `p`. The order of the elements is preserved.
250 * predicate `p`. The order of the elements is preserved.
251 */
251 */
252 def filterNot(p: A => Boolean): Repr = filter(!p(_))
252 def filterNot(p: A => Boolean): Repr = filter(!p(_))
253
253
254 def collect[B, That](pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
254 def collect[B, That](pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
255 val b = bf(repr)
255 val b = bf(repr)
256 for (x <- this) if (pf.isDefinedAt(x)) b += pf(x)
256 for (x <- this) if (pf.isDefinedAt(x)) b += pf(x)
257 b.result
257 b.result
258 }
258 }
259
259
260 /** Builds a new collection by applying an option-valued function to all
260 /** Builds a new collection by applying an option-valued function to all
261 * elements of this $coll on which the function is defined.
261 * elements of this $coll on which the function is defined.
262 *
262 *
263 * @param f the option-valued function which filters and maps the $coll.
263 * @param f the option-valued function which filters and maps the $coll.
264 * @tparam B the element type of the returned collection.
264 * @tparam B the element type of the returned collection.
265 * @tparam That $thatinfo
265 * @tparam That $thatinfo
266 * @param bf $bfinfo
266 * @param bf $bfinfo
267 * @return a new collection of type `That` resulting from applying the option-valued function
267 * @return a new collection of type `That` resulting from applying the option-valued function
268 * `f` to each element and collecting all defined results.
268 * `f` to each element and collecting all defined results.
269 * The order of the elements is preserved.
269 * The order of the elements is preserved.
270 *
270 *
271 * @usecase def filterMap[B](f: A => Option[B]): $Coll[B]
271 * @usecase def filterMap[B](f: A => Option[B]): $Coll[B]
272 *
272 *
273 * @param pf the partial function which filters and maps the $coll.
273 * @param pf the partial function which filters and maps the $coll.
274 * @return a new $coll resulting from applying the given option-valued function
274 * @return a new $coll resulting from applying the given option-valued function
275 * `f` to each element and collecting all defined results.
275 * `f` to each element and collecting all defined results.
276 * The order of the elements is preserved.
276 * The order of the elements is preserved.
277 def filterMap[B, That](f: A => Option[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
277 def filterMap[B, That](f: A => Option[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
278 val b = bf(repr)
278 val b = bf(repr)
279 for (x <- this)
279 for (x <- this)
280 f(x) match {
280 f(x) match {
281 case Some(y) => b += y
281 case Some(y) => b += y
282 case _ =>
282 case _ =>
283 }
283 }
284 b.result
284 b.result
285 }
285 }
286 */
286 */
287
287
288 /** Partitions this $coll in two ${coll}s according to a predicate.
288 /** Partitions this $coll in two ${coll}s according to a predicate.
289 *
289 *
290 * @param p the predicate on which to partition.
290 * @param p the predicate on which to partition.
291 * @return a pair of ${coll}s: the first $coll consists of all elements that
291 * @return a pair of ${coll}s: the first $coll consists of all elements that
292 * satisfy the predicate `p` and the second $coll consists of all elements
292 * satisfy the predicate `p` and the second $coll consists of all elements
293 * that don't. The relative order of the elements in the resulting ${coll}s
293 * that don't. The relative order of the elements in the resulting ${coll}s
294 * is the same as in the original $coll.
294 * is the same as in the original $coll.
295 */
295 */
296 def partition(p: A => Boolean): (Repr, Repr) = {
296 def partition(p: A => Boolean): (Repr, Repr) = {
297 val l, r = newBuilder
297 val l, r = newBuilder
298 for (x <- this) (if (p(x)) l else r) += x
298 for (x <- this) (if (p(x)) l else r) += x
299 (l.result, r.result)
299 (l.result, r.result)
300 }
300 }
301
301
302 def groupBy[K](f: A => K): immutable.Map[K, Repr] = {
302 def groupBy[K](f: A => K): immutable.Map[K, Repr] = {
303 val m = mutable.Map.empty[K, Builder[A, Repr]]
303 val m = mutable.Map.empty[K, Builder[A, Repr]]
304 for (elem <- this) {
304 for (elem <- this) {
305 val key = f(elem)
305 val key = f(elem)
306 val bldr = m.getOrElseUpdate(key, newBuilder)
306 val bldr = m.getOrElseUpdate(key, newBuilder)
307 bldr += elem
307 bldr += elem
308 }
308 }
309 val b = immutable.Map.newBuilder[K, Repr]
309 val b = immutable.Map.newBuilder[K, Repr]
310 for ((k, v) <- m)
310 for ((k, v) <- m)
311 b += ((k, v.result))
311 b += ((k, v.result))
312
312
313 b.result
313 b.result
314 }
314 }
315
315
316 /** Tests whether a predicate holds for all elements of this $coll.
316 /** Tests whether a predicate holds for all elements of this $coll.
317 *
317 *
318 * $mayNotTerminateInf
318 * $mayNotTerminateInf
319 *
319 *
320 * @param p the predicate used to test elements.
320 * @param p the predicate used to test elements.
321 * @return `true` if the given predicate `p` holds for all elements
321 * @return `true` if the given predicate `p` holds for all elements
322 * of this $coll, otherwise `false`.
322 * of this $coll, otherwise `false`.
323 */
323 */
324 def forall(p: A => Boolean): Boolean = {
324 def forall(p: A => Boolean): Boolean = {
325 var result = true
325 var result = true
326 breakable {
326 breakable {
327 for (x <- this)
327 for (x <- this)
328 if (!p(x)) { result = false; break }
328 if (!p(x)) { result = false; break }
329 }
329 }
330 result
330 result
331 }
331 }
332
332
333 /** Tests whether a predicate holds for some of the elements of this $coll.
333 /** Tests whether a predicate holds for some of the elements of this $coll.
334 *
334 *
335 * $mayNotTerminateInf
335 * $mayNotTerminateInf
336 *
336 *
337 * @param p the predicate used to test elements.
337 * @param p the predicate used to test elements.
338 * @return `true` if the given predicate `p` holds for some of the
338 * @return `true` if the given predicate `p` holds for some of the
339 * elements of this $coll, otherwise `false`.
339 * elements of this $coll, otherwise `false`.
340 */
340 */
341 def exists(p: A => Boolean): Boolean = {
341 def exists(p: A => Boolean): Boolean = {
342 var result = false
342 var result = false
343 breakable {
343 breakable {
344 for (x <- this)
344 for (x <- this)
345 if (p(x)) { result = true; break }
345 if (p(x)) { result = true; break }
346 }
346 }
347 result
347 result
348 }
348 }
349
349
350 /** Finds the first element of the $coll satisfying a predicate, if any.
350 /** Finds the first element of the $coll satisfying a predicate, if any.
351 *
351 *
352 * $mayNotTerminateInf
352 * $mayNotTerminateInf
353 * $orderDependent
353 * $orderDependent
354 *
354 *
355 * @param p the predicate used to test elements.
355 * @param p the predicate used to test elements.
356 * @return an option value containing the first element in the $coll
356 * @return an option value containing the first element in the $coll
357 * that satisfies `p`, or `None` if none exists.
357 * that satisfies `p`, or `None` if none exists.
358 */
358 */
359 def find(p: A => Boolean): Option[A] = {
359 def find(p: A => Boolean): Option[A] = {
360 var result: Option[A] = None
360 var result: Option[A] = None
361 breakable {
361 breakable {
362 for (x <- this)
362 for (x <- this)
363 if (p(x)) { result = Some(x); break }
363 if (p(x)) { result = Some(x); break }
364 }
364 }
365 result
365 result
366 }
366 }
367
367
368 def scan[B >: A, That](z: B)(op: (B, B) => B)(implicit cbf: CanBuildFrom[Repr, B, That]): That = scanLeft(z)(op)
368 def scan[B >: A, That](z: B)(op: (B, B) => B)(implicit cbf: CanBuildFrom[Repr, B, That]): That = scanLeft(z)(op)
369
369
370 def scanLeft[B, That](z: B)(op: (B, A) => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
370 def scanLeft[B, That](z: B)(op: (B, A) => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
371 val b = bf(repr)
371 val b = bf(repr)
372 b.sizeHint(this, 1)
372 b.sizeHint(this, 1)
373 var acc = z
373 var acc = z
374 b += acc
374 b += acc
375 for (x <- this) { acc = op(acc, x); b += acc }
375 for (x <- this) { acc = op(acc, x); b += acc }
376 b.result
376 b.result
377 }
377 }
378
378
379 @migration(2, 9,
379 @migration(2, 9,
380 "This scanRight definition has changed in 2.9.\n" +
380 "This scanRight definition has changed in 2.9.\n" +
381 "The previous behavior can be reproduced with scanRight.reverse."
381 "The previous behavior can be reproduced with scanRight.reverse."
382 )
382 )
383 def scanRight[B, That](z: B)(op: (A, B) => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
383 def scanRight[B, That](z: B)(op: (A, B) => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
384 var scanned = List(z)
384 var scanned = List(z)
385 var acc = z
385 var acc = z
386 for (x <- reversed) {
386 for (x <- reversed) {
387 acc = op(x, acc)
387 acc = op(x, acc)
388 scanned ::= acc
388 scanned ::= acc
389 }
389 }
390 val b = bf(repr)
390 val b = bf(repr)
391 for (elem <- scanned) b += elem
391 for (elem <- scanned) b += elem
392 b.result
392 b.result
393 }
393 }
394
394
395 /** Selects the first element of this $coll.
395 /** Selects the first element of this $coll.
396 * $orderDependent
396 * $orderDependent
397 * @return the first element of this $coll.
397 * @return the first element of this $coll.
398 * @throws `NoSuchElementException` if the $coll is empty.
398 * @throws `NoSuchElementException` if the $coll is empty.
399 */
399 */
400 def head: A = {
400 def head: A = {
401 var result: () => A = () => throw new NoSuchElementException
401 var result: () => A = () => throw new NoSuchElementException
402 breakable {
402 breakable {
403 for (x <- this) {
403 for (x <- this) {
404 result = () => x
404 result = () => x
405 break
405 break
406 }
406 }
407 }
407 }
408 result()
408 result()
409 }
409 }
410
410
411 /** Optionally selects the first element.
411 /** Optionally selects the first element.
412 * $orderDependent
412 * $orderDependent
413 * @return the first element of this $coll if it is nonempty, `None` if it is empty.
413 * @return the first element of this $coll if it is nonempty, `None` if it is empty.
414 */
414 */
415 def headOption: Option[A] = if (isEmpty) None else Some(head)
415 def headOption: Option[A] = if (isEmpty) None else Some(head)
416
416
417 /** Selects all elements except the first.
417 /** Selects all elements except the first.
418 * $orderDependent
418 * $orderDependent
419 * @return a $coll consisting of all elements of this $coll
419 * @return a $coll consisting of all elements of this $coll
420 * except the first one.
420 * except the first one.
421 * @throws `UnsupportedOperationException` if the $coll is empty.
421 * @throws `UnsupportedOperationException` if the $coll is empty.
422 */
422 */
423 override def tail: Repr = {
423 override def tail: Repr = {
424 if (isEmpty) throw new UnsupportedOperationException("empty.tail")
424 if (isEmpty) throw new UnsupportedOperationException("empty.tail")
425 drop(1)
425 drop(1)
426 }
426 }
427
427
428 /** Selects the last element.
428 /** Selects the last element.
429 * $orderDependent
429 * $orderDependent
430 * @return The last element of this $coll.
430 * @return The last element of this $coll.
431 * @throws NoSuchElementException If the $coll is empty.
431 * @throws NoSuchElementException If the $coll is empty.
432 */
432 */
433 def last: A = {
433 def last: A = {
434 var lst = head
434 var lst = head
435 for (x <- this)
435 for (x <- this)
436 lst = x
436 lst = x
437 lst
437 lst
438 }
438 }
439
439
440 /** Optionally selects the last element.
440 /** Optionally selects the last element.
441 * $orderDependent
441 * $orderDependent
442 * @return the last element of this $coll$ if it is nonempty, `None` if it is empty.
442 * @return the last element of this $coll$ if it is nonempty, `None` if it is empty.
443 */
443 */
444 def lastOption: Option[A] = if (isEmpty) None else Some(last)
444 def lastOption: Option[A] = if (isEmpty) None else Some(last)
445
445
446 /** Selects all elements except the last.
446 /** Selects all elements except the last.
447 * $orderDependent
447 * $orderDependent
448 * @return a $coll consisting of all elements of this $coll
448 * @return a $coll consisting of all elements of this $coll
449 * except the last one.
449 * except the last one.
450 * @throws `UnsupportedOperationException` if the $coll is empty.
450 * @throws `UnsupportedOperationException` if the $coll is empty.
451 */
451 */
452 def init: Repr = {
452 def init: Repr = {
453 if (isEmpty) throw new UnsupportedOperationException("empty.init")
453 if (isEmpty) throw new UnsupportedOperationException("empty.init")
454 var lst = head
454 var lst = head
455 var follow = false
455 var follow = false
456 val b = newBuilder
456 val b = newBuilder
457 b.sizeHint(this, -1)
457 b.sizeHint(this, -1)
458 for (x <- this.seq) {
458 for (x <- this.seq) {
459 if (follow) b += lst
459 if (follow) b += lst
460 else follow = true
460 else follow = true
461 lst = x
461 lst = x
462 }
462 }
463 b.result
463 b.result
464 }
464 }
465
465
466 def take(n: Int): Repr = slice(0, n)
466 def take(n: Int): Repr = slice(0, n)
467
467
468 def drop(n: Int): Repr =
468 def drop(n: Int): Repr =
469 if (n <= 0) {
469 if (n <= 0) {
470 val b = newBuilder
470 val b = newBuilder
471 b.sizeHint(this)
471 b.sizeHint(this)
472 b ++= thisCollection result
472 b ++= thisCollection result
473 }
473 }
474 else sliceWithKnownDelta(n, Int.MaxValue, -n)
474 else sliceWithKnownDelta(n, Int.MaxValue, -n)
475
475
476 def slice(from: Int, until: Int): Repr = sliceWithKnownBound(math.max(from, 0), until)
476 def slice(from: Int, until: Int): Repr = sliceWithKnownBound(math.max(from, 0), until)
477
477
478 // Precondition: from >= 0, until > 0, builder already configured for building.
478 // Precondition: from >= 0, until > 0, builder already configured for building.
479 private[this] def sliceInternal(from: Int, until: Int, b: Builder[A, Repr]): Repr = {
479 private[this] def sliceInternal(from: Int, until: Int, b: Builder[A, Repr]): Repr = {
480 var i = 0
480 var i = 0
481 breakable {
481 breakable {
482 for (x <- this.seq) {
482 for (x <- this.seq) {
483 if (i >= from) b += x
483 if (i >= from) b += x
484 i += 1
484 i += 1
485 if (i >= until) break
485 if (i >= until) break
486 }
486 }
487 }
487 }
488 b.result
488 b.result
489 }
489 }
490 // Precondition: from >= 0
490 // Precondition: from >= 0
491 private[scala] def sliceWithKnownDelta(from: Int, until: Int, delta: Int): Repr = {
491 private[scala] def sliceWithKnownDelta(from: Int, until: Int, delta: Int): Repr = {
492 val b = newBuilder
492 val b = newBuilder
493 if (until <= from) b.result
493 if (until <= from) b.result
494 else {
494 else {
495 b.sizeHint(this, delta)
495 b.sizeHint(this, delta)
496 sliceInternal(from, until, b)
496 sliceInternal(from, until, b)
497 }
497 }
498 }
498 }
499 // Precondition: from >= 0
499 // Precondition: from >= 0
500 private[scala] def sliceWithKnownBound(from: Int, until: Int): Repr = {
500 private[scala] def sliceWithKnownBound(from: Int, until: Int): Repr = {
501 val b = newBuilder
501 val b = newBuilder
502 if (until <= from) b.result
502 if (until <= from) b.result
503 else {
503 else {
504 b.sizeHintBounded(until - from, this)
504 b.sizeHintBounded(until - from, this)
505 sliceInternal(from, until, b)
505 sliceInternal(from, until, b)
506 }
506 }
507 }
507 }
508
508
509 def takeWhile(p: A => Boolean): Repr = {
509 def takeWhile(p: A => Boolean): Repr = {
510 val b = newBuilder
510 val b = newBuilder
511 breakable {
511 breakable {
512 for (x <- this) {
512 for (x <- this) {
513 if (!p(x)) break
513 if (!p(x)) break
514 b += x
514 b += x
515 }
515 }
516 }
516 }
517 b.result
517 b.result
518 }
518 }
519
519
520 def dropWhile(p: A => Boolean): Repr = {
520 def dropWhile(p: A => Boolean): Repr = {
521 val b = newBuilder
521 val b = newBuilder
522 var go = false
522 var go = false
523 for (x <- this) {
523 for (x <- this) {
524 if (!p(x)) go = true
524 if (!p(x)) go = true
525 if (go) b += x
525 if (go) b += x
526 }
526 }
527 b.result
527 b.result
528 }
528 }
529
529
530 def span(p: A => Boolean): (Repr, Repr) = {
530 def span(p: A => Boolean): (Repr, Repr) = {
531 val l, r = newBuilder
531 val l, r = newBuilder
532 var toLeft = true
532 var toLeft = true
533 for (x <- this) {
533 for (x <- this) {
534 toLeft = toLeft && p(x)
534 toLeft = toLeft && p(x)
535 (if (toLeft) l else r) += x
535 (if (toLeft) l else r) += x
536 }
536 }
537 (l.result, r.result)
537 (l.result, r.result)
538 }
538 }
539
539
540 def splitAt(n: Int): (Repr, Repr) = {
540 def splitAt(n: Int): (Repr, Repr) = {
541 val l, r = newBuilder
541 val l, r = newBuilder
542 l.sizeHintBounded(n, this)
542 l.sizeHintBounded(n, this)
543 if (n >= 0) r.sizeHint(this, -n)
543 if (n >= 0) r.sizeHint(this, -n)
544 var i = 0
544 var i = 0
545 for (x <- this) {
545 for (x <- this) {
546 (if (i < n) l else r) += x
546 (if (i < n) l else r) += x
547 i += 1
547 i += 1
548 }
548 }
549 (l.result, r.result)
549 (l.result, r.result)
550 }
550 }
551
551
552 /** Iterates over the tails of this $coll. The first value will be this
552 /** Iterates over the tails of this $coll. The first value will be this
553 * $coll and the final one will be an empty $coll, with the intervening
553 * $coll and the final one will be an empty $coll, with the intervening
554 * values the results of successive applications of `tail`.
554 * values the results of successive applications of `tail`.
555 *
555 *
556 * @return an iterator over all the tails of this $coll
556 * @return an iterator over all the tails of this $coll
557 * @example `List(1,2,3).tails = Iterator(List(1,2,3), List(2,3), List(3), Nil)`
557 * @example `List(1,2,3).tails = Iterator(List(1,2,3), List(2,3), List(3), Nil)`
558 */
558 */
559 def tails: Iterator[Repr] = iterateUntilEmpty(_.tail)
559 def tails: Iterator[Repr] = iterateUntilEmpty(_.tail)
560
560
561 /** Iterates over the inits of this $coll. The first value will be this
561 /** Iterates over the inits of this $coll. The first value will be this
562 * $coll and the final one will be an empty $coll, with the intervening
562 * $coll and the final one will be an empty $coll, with the intervening
563 * values the results of successive applications of `init`.
563 * values the results of successive applications of `init`.
564 *
564 *
565 * @return an iterator over all the inits of this $coll
565 * @return an iterator over all the inits of this $coll
566 * @example `List(1,2,3).inits = Iterator(List(1,2,3), List(1,2), List(1), Nil)`
566 * @example `List(1,2,3).inits = Iterator(List(1,2,3), List(1,2), List(1), Nil)`
567 */
567 */
568 def inits: Iterator[Repr] = iterateUntilEmpty(_.init)
568 def inits: Iterator[Repr] = iterateUntilEmpty(_.init)
569
569
570 /** Copies elements of this $coll to an array.
570 /** Copies elements of this $coll to an array.
571 * Fills the given array `xs` with at most `len` elements of
571 * Fills the given array `xs` with at most `len` elements of
572 * this $coll, starting at position `start`.
572 * this $coll, starting at position `start`.
573 * Copying will stop once either the end of the current $coll is reached,
573 * Copying will stop once either the end of the current $coll is reached,
574 * or the end of the array is reached, or `len` elements have been copied.
574 * or the end of the array is reached, or `len` elements have been copied.
575 *
575 *
576 * $willNotTerminateInf
576 * $willNotTerminateInf
577 *
577 *
578 * @param xs the array to fill.
578 * @param xs the array to fill.
579 * @param start the starting index.
579 * @param start the starting index.
580 * @param len the maximal number of elements to copy.
580 * @param len the maximal number of elements to copy.
581 * @tparam B the type of the elements of the array.
581 * @tparam B the type of the elements of the array.
582 *
582 *
583 *
583 *
584 * @usecase def copyToArray(xs: Array[A], start: Int, len: Int): Unit
584 * @usecase def copyToArray(xs: Array[A], start: Int, len: Int): Unit
585 */
585 */
586 def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) {
586 def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) {
587 var i = start
587 var i = start
588 val end = (start + len) min xs.length
588 val end = (start + len) min xs.length
589 breakable {
589 breakable {
590 for (x <- this) {
590 for (x <- this) {
591 if (i >= end) break
591 if (i >= end) break
592 xs(i) = x
592 xs(i) = x
593 i += 1
593 i += 1
594 }
594 }
595 }
595 }
596 }
596 }
597
597
598 def toTraversable: Traversable[A] = thisCollection
598 def toTraversable: Traversable[A] = thisCollection
599 def toIterator: Iterator[A] = toStream.iterator
599 def toIterator: Iterator[A] = toStream.iterator
600 def toStream: Stream[A] = toBuffer.toStream
600 def toStream: Stream[A] = toBuffer.toStream
601
601
602 /** Converts this $coll to a string.
602 /** Converts this $coll to a string.
603 *
603 *
604 * @return a string representation of this collection. By default this
604 * @return a string representation of this collection. By default this
605 * string consists of the `stringPrefix` of this $coll,
605 * string consists of the `stringPrefix` of this $coll,
606 * followed by all elements separated by commas and enclosed in parentheses.
606 * followed by all elements separated by commas and enclosed in parentheses.
607 */
607 */
608 override def toString = mkString(stringPrefix + "(", ", ", ")")
608 override def toString = mkString(stringPrefix + "(", ", ", ")")
609
609
610 /** Defines the prefix of this object's `toString` representation.
610 /** Defines the prefix of this object's `toString` representation.
611 *
611 *
612 * @return a string representation which starts the result of `toString`
612 * @return a string representation which starts the result of `toString`
613 * applied to this $coll. By default the string prefix is the
613 * applied to this $coll. By default the string prefix is the
614 * simple name of the collection class $coll.
614 * simple name of the collection class $coll.
615 */
615 */
616 def stringPrefix : String = {
616 def stringPrefix : String = {
617 var string = repr.asInstanceOf[AnyRef].getClass.getName
617 var string = repr.asInstanceOf[AnyRef].getClass.getName
618 val idx1 = string.lastIndexOf('.' : Int)
618 val idx1 = string.lastIndexOf('.' : Int)
619 if (idx1 != -1) string = string.substring(idx1 + 1)
619 if (idx1 != -1) string = string.substring(idx1 + 1)
620 val idx2 = string.indexOf('$')
620 val idx2 = string.indexOf('$')
621 if (idx2 != -1) string = string.substring(0, idx2)
621 if (idx2 != -1) string = string.substring(0, idx2)
622 string
622 string
623 }
623 }
624
624
625 /** Creates a non-strict view of this $coll.
625 /** Creates a non-strict view of this $coll.
626 *
626 *
627 * @return a non-strict view of this $coll.
627 * @return a non-strict view of this $coll.
628 */
628 */
629 def view = new TraversableView[A, Repr] {
629 def view = new TraversableView[A, Repr] {
630 protected lazy val underlying = self.repr
630 protected lazy val underlying = self.repr
631 override def foreach[U](f: A => U) = self foreach f
631 override def foreach[U](f: A => U) = self foreach f
632 }
632 }
633
633
634 /** Creates a non-strict view of a slice of this $coll.
634 /** Creates a non-strict view of a slice of this $coll.
635 *
635 *
636 * Note: the difference between `view` and `slice` is that `view` produces
636 * Note: the difference between `view` and `slice` is that `view` produces
637 * a view of the current $coll, whereas `slice` produces a new $coll.
637 * a view of the current $coll, whereas `slice` produces a new $coll.
638 *
638 *
639 * Note: `view(from, to)` is equivalent to `view.slice(from, to)`
639 * Note: `view(from, to)` is equivalent to `view.slice(from, to)`
640 * $orderDependent
640 * $orderDependent
641 *
641 *
642 * @param from the index of the first element of the view
642 * @param from the index of the first element of the view
643 * @param until the index of the element following the view
643 * @param until the index of the element following the view
644 * @return a non-strict view of a slice of this $coll, starting at index `from`
644 * @return a non-strict view of a slice of this $coll, starting at index `from`
645 * and extending up to (but not including) index `until`.
645 * and extending up to (but not including) index `until`.
646 */
646 */
647 def view(from: Int, until: Int): TraversableView[A, Repr] = view.slice(from, until)
647 def view(from: Int, until: Int): TraversableView[A, Repr] = view.slice(from, until)
648
648
649 /** Creates a non-strict filter of this $coll.
649 /** Creates a non-strict filter of this $coll.
650 *
650 *
651 * Note: the difference between `c filter p` and `c withFilter p` is that
651 * Note: the difference between `c filter p` and `c withFilter p` is that
652 * the former creates a new collection, whereas the latter only
652 * the former creates a new collection, whereas the latter only
653 * restricts the domain of subsequent `map`, `flatMap`, `foreach`,
653 * restricts the domain of subsequent `map`, `flatMap`, `foreach`,
654 * and `withFilter` operations.
654 * and `withFilter` operations.
655 * $orderDependent
655 * $orderDependent
656 *
656 *
657 * @param p the predicate used to test elements.
657 * @param p the predicate used to test elements.
658 * @return an object of class `WithFilter`, which supports
658 * @return an object of class `WithFilter`, which supports
659 * `map`, `flatMap`, `foreach`, and `withFilter` operations.
659 * `map`, `flatMap`, `foreach`, and `withFilter` operations.
660 * All these operations apply to those elements of this $coll which
660 * All these operations apply to those elements of this $coll which
661 * satisfy the predicate `p`.
661 * satisfy the predicate `p`.
662 */
662 */
663 def withFilter(p: A => Boolean): FilterMonadic[A, Repr] = new WithFilter(p)
663 def withFilter(p: A => Boolean): FilterMonadic[A, Repr] = new WithFilter(p)
664
664
665 /** A class supporting filtered operations. Instances of this class are
665 /** A class supporting filtered operations. Instances of this class are
666 * returned by method `withFilter`.
666 * returned by method `withFilter`.
667 */
667 */
668 class WithFilter(p: A => Boolean) extends FilterMonadic[A, Repr] {
668 class WithFilter(p: A => Boolean) extends FilterMonadic[A, Repr] {
669
669
670 /** Builds a new collection by applying a function to all elements of the
670 /** Builds a new collection by applying a function to all elements of the
671 * outer $coll containing this `WithFilter` instance that satisfy predicate `p`.
671 * outer $coll containing this `WithFilter` instance that satisfy predicate `p`.
672 *
672 *
673 * @param f the function to apply to each element.
673 * @param f the function to apply to each element.
674 * @tparam B the element type of the returned collection.
674 * @tparam B the element type of the returned collection.
675 * @tparam That $thatinfo
675 * @tparam That $thatinfo
676 * @param bf $bfinfo
676 * @param bf $bfinfo
677 * @return a new collection of type `That` resulting from applying
677 * @return a new collection of type `That` resulting from applying
678 * the given function `f` to each element of the outer $coll
678 * the given function `f` to each element of the outer $coll
679 * that satisfies predicate `p` and collecting the results.
679 * that satisfies predicate `p` and collecting the results.
680 *
680 *
681 * @usecase def map[B](f: A => B): $Coll[B]
681 * @usecase def map[B](f: A => B): $Coll[B]
682 *
682 *
683 * @return a new $coll resulting from applying the given function
683 * @return a new $coll resulting from applying the given function
684 * `f` to each element of the outer $coll that satisfies
684 * `f` to each element of the outer $coll that satisfies
685 * predicate `p` and collecting the results.
685 * predicate `p` and collecting the results.
686 */
686 */
687 def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
687 def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
688 val b = bf(repr)
688 val b = bf(repr)
689 for (x <- self)
689 for (x <- self)
690 if (p(x)) b += f(x)
690 if (p(x)) b += f(x)
691 b.result
691 b.result
692 }
692 }
693
693
694 /** Builds a new collection by applying a function to all elements of the
694 /** Builds a new collection by applying a function to all elements of the
695 * outer $coll containing this `WithFilter` instance that satisfy
695 * outer $coll containing this `WithFilter` instance that satisfy
696 * predicate `p` and concatenating the results.
696 * predicate `p` and concatenating the results.
697 *
697 *
698 * @param f the function to apply to each element.
698 * @param f the function to apply to each element.
699 * @tparam B the element type of the returned collection.
699 * @tparam B the element type of the returned collection.
700 * @tparam That $thatinfo
700 * @tparam That $thatinfo
701 * @param bf $bfinfo
701 * @param bf $bfinfo
702 * @return a new collection of type `That` resulting from applying
702 * @return a new collection of type `That` resulting from applying
703 * the given collection-valued function `f` to each element
703 * the given collection-valued function `f` to each element
704 * of the outer $coll that satisfies predicate `p` and
704 * of the outer $coll that satisfies predicate `p` and
705 * concatenating the results.
705 * concatenating the results.
706 *
706 *
707 * @usecase def flatMap[B](f: A => TraversableOnce[B]): $Coll[B]
707 * @usecase def flatMap[B](f: A => TraversableOnce[B]): $Coll[B]
708 *
708 *
709 * @return a new $coll resulting from applying the given collection-valued function
709 * @return a new $coll resulting from applying the given collection-valued function
710 * `f` to each element of the outer $coll that satisfies predicate `p` and concatenating the results.
710 * `f` to each element of the outer $coll that satisfies predicate `p` and concatenating the results.
711 */
711 */
712 def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
712 def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
713 val b = bf(repr)
713 val b = bf(repr)
714 for (x <- self)
714 for (x <- self)
715 if (p(x)) b ++= f(x).seq
715 if (p(x)) b ++= f(x).seq
716 b.result
716 b.result
717 }
717 }
718
718
719 /** Applies a function `f` to all elements of the outer $coll containing
719 /** Applies a function `f` to all elements of the outer $coll containing
720 * this `WithFilter` instance that satisfy predicate `p`.
720 * this `WithFilter` instance that satisfy predicate `p`.
721 *
721 *
722 * @param f the function that is applied for its side-effect to every element.
722 * @param f the function that is applied for its side-effect to every element.
723 * The result of function `f` is discarded.
723 * The result of function `f` is discarded.
724 *
724 *
725 * @tparam U the type parameter describing the result of function `f`.
725 * @tparam U the type parameter describing the result of function `f`.
726 * This result will always be ignored. Typically `U` is `Unit`,
726 * This result will always be ignored. Typically `U` is `Unit`,
727 * but this is not necessary.
727 * but this is not necessary.
728 *
728 *
729 * @usecase def foreach(f: A => Unit): Unit
729 * @usecase def foreach(f: A => Unit): Unit
730 */
730 */
731 def foreach[U](f: A => U): Unit =
731 def foreach[U](f: A => U): Unit =
732 for (x <- self)
732 for (x <- self)
733 if (p(x)) f(x)
733 if (p(x)) f(x)
734
734
735 /** Further refines the filter for this $coll.
735 /** Further refines the filter for this $coll.
736 *
736 *
737 * @param q the predicate used to test elements.
737 * @param q the predicate used to test elements.
738 * @return an object of class `WithFilter`, which supports
738 * @return an object of class `WithFilter`, which supports
739 * `map`, `flatMap`, `foreach`, and `withFilter` operations.
739 * `map`, `flatMap`, `foreach`, and `withFilter` operations.
740 * All these operations apply to those elements of this $coll which
740 * All these operations apply to those elements of this $coll which
741 * satisfy the predicate `q` in addition to the predicate `p`.
741 * satisfy the predicate `q` in addition to the predicate `p`.
742 */
742 */
743 def withFilter(q: A => Boolean): WithFilter =
743 def withFilter(q: A => Boolean): WithFilter =
744 new WithFilter(x => p(x) && q(x))
744 new WithFilter(x => p(x) && q(x))
745 }
745 }
746
746
747 // A helper for tails and inits.
747 // A helper for tails and inits.
748 private def iterateUntilEmpty(f: Traversable[A @uV] => Traversable[A @uV]): Iterator[Repr] = {
748 private def iterateUntilEmpty(f: Traversable[A @uV] => Traversable[A @uV]): Iterator[Repr] = {
749 val it = Iterator.iterate(thisCollection)(f) takeWhile (x => !x.isEmpty)
749 val it = Iterator.iterate(thisCollection)(f) takeWhile (x => !x.isEmpty)
750 it ++ Iterator(Nil) map (newBuilder ++= _ result)
750 it ++ Iterator(Nil) map (newBuilder ++= _ result)
751 }
751 }
752 }
752 }
753
753
754
754
755 </textarea>
755 </textarea>
756 </form>
756 </form>
757
757
758 <script>
758 <script>
759 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
759 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
760 lineNumbers: true,
760 lineNumbers: true,
761 matchBrackets: true,
761 matchBrackets: true,
762 theme: "ambiance",
762 theme: "ambiance",
763 mode: "text/x-scala"
763 mode: "text/x-scala"
764 });
764 });
765 </script>
765 </script>
766 </body>
766 </body>
767 </html>
767 </html>
@@ -1,195 +1,195 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: COBOL mode</title>
5 <title>CodeMirror: COBOL mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="../../addon/edit/matchbrackets.js"></script>
8 <script src="../../addon/edit/matchbrackets.js"></script>
9 <script src="cobol.js"></script>
9 <script src="cobol.js"></script>
10 <link rel="stylesheet" href="../../theme/neat.css">
10 <link rel="stylesheet" href="../../theme/neat.css">
11 <link rel="stylesheet" href="../../theme/elegant.css">
11 <link rel="stylesheet" href="../../theme/elegant.css">
12 <link rel="stylesheet" href="../../theme/erlang-dark.css">
12 <link rel="stylesheet" href="../../theme/erlang-dark.css">
13 <link rel="stylesheet" href="../../theme/night.css">
13 <link rel="stylesheet" href="../../theme/night.css">
14 <link rel="stylesheet" href="../../theme/monokai.css">
14 <link rel="stylesheet" href="../../theme/monokai.css">
15 <link rel="stylesheet" href="../../theme/cobalt.css">
15 <link rel="stylesheet" href="../../theme/cobalt.css">
16 <link rel="stylesheet" href="../../theme/eclipse.css">
16 <link rel="stylesheet" href="../../theme/eclipse.css">
17 <link rel="stylesheet" href="../../theme/rubyblue.css">
17 <link rel="stylesheet" href="../../theme/rubyblue.css">
18 <link rel="stylesheet" href="../../theme/lesser-dark.css">
18 <link rel="stylesheet" href="../../theme/lesser-dark.css">
19 <link rel="stylesheet" href="../../theme/xq-dark.css">
19 <link rel="stylesheet" href="../../theme/xq-dark.css">
20 <link rel="stylesheet" href="../../theme/xq-light.css">
20 <link rel="stylesheet" href="../../theme/xq-light.css">
21 <link rel="stylesheet" href="../../theme/ambiance.css">
21 <link rel="stylesheet" href="../../theme/ambiance.css">
22 <link rel="stylesheet" href="../../theme/blackboard.css">
22 <link rel="stylesheet" href="../../theme/blackboard.css">
23 <link rel="stylesheet" href="../../theme/vibrant-ink.css">
23 <link rel="stylesheet" href="../../theme/vibrant-ink.css">
24 <link rel="stylesheet" href="../../theme/solarized.css">
24 <link rel="stylesheet" href="../../theme/solarized.css">
25 <link rel="stylesheet" href="../../theme/twilight.css">
25 <link rel="stylesheet" href="../../theme/twilight.css">
26 <link rel="stylesheet" href="../../theme/midnight.css">
26 <link rel="stylesheet" href="../../theme/midnight.css">
27 <link rel="stylesheet" href="../../addon/dialog/dialog.css">
27 <link rel="stylesheet" href="../../addon/dialog/dialog.css">
28 <script src="../../addon/selection/active-line.js"></script>
28 <script src="../../addon/selection/active-line.js"></script>
29 <script src="../../addon/search/search.js"></script>
29 <script src="../../addon/search/search.js"></script>
30 <script src="../../addon/dialog/dialog.js"></script>
30 <script src="../../addon/dialog/dialog.js"></script>
31 <script src="../../addon/search/searchcursor.js"></script>
31 <script src="../../addon/search/searchcursor.js"></script>
32 <style>
32 <style>
33 .CodeMirror {
33 .CodeMirror {
34 border: 1px solid #eee;
34 border: 1px solid #eee;
35 font-size : 20px;
35 font-size : 20px;
36 height : auto !important;
36 height : auto !important;
37 }
37 }
38 .CodeMirror-activeline-background {background: #555555 !important;}
38 .CodeMirror-activeline-background {background: #555555 !important;}
39 </style>
39 </style>
40 </head>
40 </head>
41 <body>
41 <body>
42 <p> Select Theme <select onchange="selectTheme()" id="selectTheme">
42 <p> Select Theme <select onchange="selectTheme()" id="selectTheme">
43 <option>default</option>
43 <option>default</option>
44 <option>ambiance</option>
44 <option>ambiance</option>
45 <option>blackboard</option>
45 <option>blackboard</option>
46 <option>cobalt</option>
46 <option>cobalt</option>
47 <option>eclipse</option>
47 <option>eclipse</option>
48 <option>elegant</option>
48 <option>elegant</option>
49 <option>erlang-dark</option>
49 <option>erlang-dark</option>
50 <option>lesser-dark</option>
50 <option>lesser-dark</option>
51 <option>midnight</option>
51 <option>midnight</option>
52 <option>monokai</option>
52 <option>monokai</option>
53 <option>neat</option>
53 <option>neat</option>
54 <option>night</option>
54 <option>night</option>
55 <option>rubyblue</option>
55 <option>rubyblue</option>
56 <option>solarized dark</option>
56 <option>solarized dark</option>
57 <option>solarized light</option>
57 <option>solarized light</option>
58 <option selected>twilight</option>
58 <option selected>twilight</option>
59 <option>vibrant-ink</option>
59 <option>vibrant-ink</option>
60 <option>xq-dark</option>
60 <option>xq-dark</option>
61 <option>xq-light</option>
61 <option>xq-light</option>
62 </select> Select Font Size <select onchange="selectFontsize()" id="selectFontSize">
62 </select> Select Font Size <select onchange="selectFontsize()" id="selectFontSize">
63 <option value="13px">13px</option>
63 <option value="13px">13px</option>
64 <option value="14px">14px</option>
64 <option value="14px">14px</option>
65 <option value="16px">16px</option>
65 <option value="16px">16px</option>
66 <option value="18px">18px</option>
66 <option value="18px">18px</option>
67 <option value="20px" selected="selected">20px</option>
67 <option value="20px" selected="selected">20px</option>
68 <option value="24px">24px</option>
68 <option value="24px">24px</option>
69 <option value="26px">26px</option>
69 <option value="26px">26px</option>
70 <option value="28px">28px</option>
70 <option value="28px">28px</option>
71 <option value="30px">30px</option>
71 <option value="30px">30px</option>
72 <option value="32px">32px</option>
72 <option value="32px">32px</option>
73 <option value="34px">34px</option>
73 <option value="34px">34px</option>
74 <option value="36px">36px</option>
74 <option value="36px">36px</option>
75 </select>
75 </select>
76 <label for="checkBoxReadOnly">Read-only</label>
76 <label for="checkBoxReadOnly">Read-only</label>
77 <input type="checkbox" id="checkBoxReadOnly" onchange="selectReadOnly()">
77 <input type="checkbox" id="checkBoxReadOnly" onchange="selectReadOnly()">
78 <label for="id_tabToIndentSpace">Insert Spaces on Tab</label>
78 <label for="id_tabToIndentSpace">Insert Spaces on Tab</label>
79 <input type="checkbox" id="id_tabToIndentSpace" onchange="tabToIndentSpace()">
79 <input type="checkbox" id="id_tabToIndentSpace" onchange="tabToIndentSpace()">
80 </p>
80 </p>
81 <textarea id="code" name="code">
81 <textarea id="code" name="code">
82 ---------1---------2---------3---------4---------5---------6---------7---------8
82 ---------1---------2---------3---------4---------5---------6---------7---------8
83 12345678911234567892123456789312345678941234567895123456789612345678971234567898
83 12345678911234567892123456789312345678941234567895123456789612345678971234567898
84 000010 IDENTIFICATION DIVISION. MODTGHERE
84 000010 IDENTIFICATION DIVISION. MODTGHERE
85 000020 PROGRAM-ID. SAMPLE.
85 000020 PROGRAM-ID. SAMPLE.
86 000030 AUTHOR. TEST SAM.
86 000030 AUTHOR. TEST SAM.
87 000040 DATE-WRITTEN. 5 February 2013
87 000040 DATE-WRITTEN. 5 February 2013
88 000041
88 000041
89 000042* A sample program just to show the form.
89 000042* A sample program just to show the form.
90 000043* The program copies its input to the output,
90 000043* The program copies its input to the output,
91 000044* and counts the number of records.
91 000044* and counts the number of records.
92 000045* At the end this number is printed.
92 000045* At the end this number is printed.
93 000046
93 000046
94 000050 ENVIRONMENT DIVISION.
94 000050 ENVIRONMENT DIVISION.
95 000060 INPUT-OUTPUT SECTION.
95 000060 INPUT-OUTPUT SECTION.
96 000070 FILE-CONTROL.
96 000070 FILE-CONTROL.
97 000080 SELECT STUDENT-FILE ASSIGN TO SYSIN
97 000080 SELECT STUDENT-FILE ASSIGN TO SYSIN
98 000090 ORGANIZATION IS LINE SEQUENTIAL.
98 000090 ORGANIZATION IS LINE SEQUENTIAL.
99 000100 SELECT PRINT-FILE ASSIGN TO SYSOUT
99 000100 SELECT PRINT-FILE ASSIGN TO SYSOUT
100 000110 ORGANIZATION IS LINE SEQUENTIAL.
100 000110 ORGANIZATION IS LINE SEQUENTIAL.
101 000120
101 000120
102 000130 DATA DIVISION.
102 000130 DATA DIVISION.
103 000140 FILE SECTION.
103 000140 FILE SECTION.
104 000150 FD STUDENT-FILE
104 000150 FD STUDENT-FILE
105 000160 RECORD CONTAINS 43 CHARACTERS
105 000160 RECORD CONTAINS 43 CHARACTERS
106 000170 DATA RECORD IS STUDENT-IN.
106 000170 DATA RECORD IS STUDENT-IN.
107 000180 01 STUDENT-IN PIC X(43).
107 000180 01 STUDENT-IN PIC X(43).
108 000190
108 000190
109 000200 FD PRINT-FILE
109 000200 FD PRINT-FILE
110 000210 RECORD CONTAINS 80 CHARACTERS
110 000210 RECORD CONTAINS 80 CHARACTERS
111 000220 DATA RECORD IS PRINT-LINE.
111 000220 DATA RECORD IS PRINT-LINE.
112 000230 01 PRINT-LINE PIC X(80).
112 000230 01 PRINT-LINE PIC X(80).
113 000240
113 000240
114 000250 WORKING-STORAGE SECTION.
114 000250 WORKING-STORAGE SECTION.
115 000260 01 DATA-REMAINS-SWITCH PIC X(2) VALUE SPACES.
115 000260 01 DATA-REMAINS-SWITCH PIC X(2) VALUE SPACES.
116 000261 01 RECORDS-WRITTEN PIC 99.
116 000261 01 RECORDS-WRITTEN PIC 99.
117 000270
117 000270
118 000280 01 DETAIL-LINE.
118 000280 01 DETAIL-LINE.
119 000290 05 FILLER PIC X(7) VALUE SPACES.
119 000290 05 FILLER PIC X(7) VALUE SPACES.
120 000300 05 RECORD-IMAGE PIC X(43).
120 000300 05 RECORD-IMAGE PIC X(43).
121 000310 05 FILLER PIC X(30) VALUE SPACES.
121 000310 05 FILLER PIC X(30) VALUE SPACES.
122 000311
122 000311
123 000312 01 SUMMARY-LINE.
123 000312 01 SUMMARY-LINE.
124 000313 05 FILLER PIC X(7) VALUE SPACES.
124 000313 05 FILLER PIC X(7) VALUE SPACES.
125 000314 05 TOTAL-READ PIC 99.
125 000314 05 TOTAL-READ PIC 99.
126 000315 05 FILLER PIC X VALUE SPACE.
126 000315 05 FILLER PIC X VALUE SPACE.
127 000316 05 FILLER PIC X(17)
127 000316 05 FILLER PIC X(17)
128 000317 VALUE 'Records were read'.
128 000317 VALUE 'Records were read'.
129 000318 05 FILLER PIC X(53) VALUE SPACES.
129 000318 05 FILLER PIC X(53) VALUE SPACES.
130 000319
130 000319
131 000320 PROCEDURE DIVISION.
131 000320 PROCEDURE DIVISION.
132 000321
132 000321
133 000330 PREPARE-SENIOR-REPORT.
133 000330 PREPARE-SENIOR-REPORT.
134 000340 OPEN INPUT STUDENT-FILE
134 000340 OPEN INPUT STUDENT-FILE
135 000350 OUTPUT PRINT-FILE.
135 000350 OUTPUT PRINT-FILE.
136 000351 MOVE ZERO TO RECORDS-WRITTEN.
136 000351 MOVE ZERO TO RECORDS-WRITTEN.
137 000360 READ STUDENT-FILE
137 000360 READ STUDENT-FILE
138 000370 AT END MOVE 'NO' TO DATA-REMAINS-SWITCH
138 000370 AT END MOVE 'NO' TO DATA-REMAINS-SWITCH
139 000380 END-READ.
139 000380 END-READ.
140 000390 PERFORM PROCESS-RECORDS
140 000390 PERFORM PROCESS-RECORDS
141 000410 UNTIL DATA-REMAINS-SWITCH = 'NO'.
141 000410 UNTIL DATA-REMAINS-SWITCH = 'NO'.
142 000411 PERFORM PRINT-SUMMARY.
142 000411 PERFORM PRINT-SUMMARY.
143 000420 CLOSE STUDENT-FILE
143 000420 CLOSE STUDENT-FILE
144 000430 PRINT-FILE.
144 000430 PRINT-FILE.
145 000440 STOP RUN.
145 000440 STOP RUN.
146 000450
146 000450
147 000460 PROCESS-RECORDS.
147 000460 PROCESS-RECORDS.
148 000470 MOVE STUDENT-IN TO RECORD-IMAGE.
148 000470 MOVE STUDENT-IN TO RECORD-IMAGE.
149 000480 MOVE DETAIL-LINE TO PRINT-LINE.
149 000480 MOVE DETAIL-LINE TO PRINT-LINE.
150 000490 WRITE PRINT-LINE.
150 000490 WRITE PRINT-LINE.
151 000500 ADD 1 TO RECORDS-WRITTEN.
151 000500 ADD 1 TO RECORDS-WRITTEN.
152 000510 READ STUDENT-FILE
152 000510 READ STUDENT-FILE
153 000520 AT END MOVE 'NO' TO DATA-REMAINS-SWITCH
153 000520 AT END MOVE 'NO' TO DATA-REMAINS-SWITCH
154 000530 END-READ.
154 000530 END-READ.
155 000540
155 000540
156 000550 PRINT-SUMMARY.
156 000550 PRINT-SUMMARY.
157 000560 MOVE RECORDS-WRITTEN TO TOTAL-READ.
157 000560 MOVE RECORDS-WRITTEN TO TOTAL-READ.
158 000570 MOVE SUMMARY-LINE TO PRINT-LINE.
158 000570 MOVE SUMMARY-LINE TO PRINT-LINE.
159 000571 WRITE PRINT-LINE.
159 000571 WRITE PRINT-LINE.
160 000572
160 000572
161 000580
161 000580
162 </textarea>
162 </textarea>
163 <script>
163 <script>
164 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
164 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
165 lineNumbers: true,
165 lineNumbers: true,
166 matchBrackets: true,
166 matchBrackets: true,
167 mode: "text/x-cobol",
167 mode: "text/x-cobol",
168 theme : "twilight",
168 theme : "twilight",
169 styleActiveLine: true,
169 styleActiveLine: true,
170 showCursorWhenSelecting : true,
170 showCursorWhenSelecting : true,
171 });
171 });
172 function selectTheme() {
172 function selectTheme() {
173 var themeInput = document.getElementById("selectTheme");
173 var themeInput = document.getElementById("selectTheme");
174 var theme = themeInput.options[themeInput.selectedIndex].innerHTML;
174 var theme = themeInput.options[themeInput.selectedIndex].innerHTML;
175 editor.setOption("theme", theme);
175 editor.setOption("theme", theme);
176 }
176 }
177 function selectFontsize() {
177 function selectFontsize() {
178 var fontSizeInput = document.getElementById("selectFontSize");
178 var fontSizeInput = document.getElementById("selectFontSize");
179 var fontSize = fontSizeInput.options[fontSizeInput.selectedIndex].innerHTML;
179 var fontSize = fontSizeInput.options[fontSizeInput.selectedIndex].innerHTML;
180 editor.getWrapperElement().style["font-size"] = fontSize;
180 editor.getWrapperElement().style["font-size"] = fontSize;
181 editor.refresh();
181 editor.refresh();
182 }
182 }
183 function selectReadOnly() {
183 function selectReadOnly() {
184 editor.setOption("readOnly", document.getElementById("checkBoxReadOnly").checked);
184 editor.setOption("readOnly", document.getElementById("checkBoxReadOnly").checked);
185 }
185 }
186 function tabToIndentSpace() {
186 function tabToIndentSpace() {
187 if (document.getElementById("id_tabToIndentSpace").checked) {
187 if (document.getElementById("id_tabToIndentSpace").checked) {
188 editor.setOption("extraKeys", {Tab: function(cm) { cm.replaceSelection(" ", "end"); }});
188 editor.setOption("extraKeys", {Tab: function(cm) { cm.replaceSelection(" ", "end"); }});
189 } else {
189 } else {
190 editor.setOption("extraKeys", {Tab: function(cm) { cm.replaceSelection(" ", "end"); }});
190 editor.setOption("extraKeys", {Tab: function(cm) { cm.replaceSelection(" ", "end"); }});
191 }
191 }
192 }
192 }
193 </script>
193 </script>
194 </body>
194 </body>
195 </html>
195 </html>
@@ -1,728 +1,728 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: CoffeeScript mode</title>
5 <title>CodeMirror: CoffeeScript mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="coffeescript.js"></script>
8 <script src="coffeescript.js"></script>
9 <style>.CodeMirror {border-top: 1px solid silver; border-bottom: 1px solid silver;}</style>
9 <style>.CodeMirror {border-top: 1px solid silver; border-bottom: 1px solid silver;}</style>
10 <link rel="stylesheet" href="../../doc/docs.css">
10 <link rel="stylesheet" href="../../doc/docs.css">
11 </head>
11 </head>
12 <body>
12 <body>
13 <h1>CodeMirror: CoffeeScript mode</h1>
13 <h1>CodeMirror: CoffeeScript mode</h1>
14 <form><textarea id="code" name="code">
14 <form><textarea id="code" name="code">
15 # CoffeeScript mode for CodeMirror
15 # CoffeeScript mode for CodeMirror
16 # Copyright (c) 2011 Jeff Pickhardt, released under
16 # Copyright (c) 2011 Jeff Pickhardt, released under
17 # the MIT License.
17 # the MIT License.
18 #
18 #
19 # Modified from the Python CodeMirror mode, which also is
19 # Modified from the Python CodeMirror mode, which also is
20 # under the MIT License Copyright (c) 2010 Timothy Farrell.
20 # under the MIT License Copyright (c) 2010 Timothy Farrell.
21 #
21 #
22 # The following script, Underscore.coffee, is used to
22 # The following script, Underscore.coffee, is used to
23 # demonstrate CoffeeScript mode for CodeMirror.
23 # demonstrate CoffeeScript mode for CodeMirror.
24 #
24 #
25 # To download CoffeeScript mode for CodeMirror, go to:
25 # To download CoffeeScript mode for CodeMirror, go to:
26 # https://github.com/pickhardt/coffeescript-codemirror-mode
26 # https://github.com/pickhardt/coffeescript-codemirror-mode
27
27
28 # **Underscore.coffee
28 # **Underscore.coffee
29 # (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.**
29 # (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.**
30 # Underscore is freely distributable under the terms of the
30 # Underscore is freely distributable under the terms of the
31 # [MIT license](http://en.wikipedia.org/wiki/MIT_License).
31 # [MIT license](http://en.wikipedia.org/wiki/MIT_License).
32 # Portions of Underscore are inspired by or borrowed from
32 # Portions of Underscore are inspired by or borrowed from
33 # [Prototype.js](http://prototypejs.org/api), Oliver Steele's
33 # [Prototype.js](http://prototypejs.org/api), Oliver Steele's
34 # [Functional](http://osteele.com), and John Resig's
34 # [Functional](http://osteele.com), and John Resig's
35 # [Micro-Templating](http://ejohn.org).
35 # [Micro-Templating](http://ejohn.org).
36 # For all details and documentation:
36 # For all details and documentation:
37 # http://documentcloud.github.com/underscore/
37 # http://documentcloud.github.com/underscore/
38
38
39
39
40 # Baseline setup
40 # Baseline setup
41 # --------------
41 # --------------
42
42
43 # Establish the root object, `window` in the browser, or `global` on the server.
43 # Establish the root object, `window` in the browser, or `global` on the server.
44 root = this
44 root = this
45
45
46
46
47 # Save the previous value of the `_` variable.
47 # Save the previous value of the `_` variable.
48 previousUnderscore = root._
48 previousUnderscore = root._
49
49
50 ### Multiline
50 ### Multiline
51 comment
51 comment
52 ###
52 ###
53
53
54 # Establish the object that gets thrown to break out of a loop iteration.
54 # Establish the object that gets thrown to break out of a loop iteration.
55 # `StopIteration` is SOP on Mozilla.
55 # `StopIteration` is SOP on Mozilla.
56 breaker = if typeof(StopIteration) is 'undefined' then '__break__' else StopIteration
56 breaker = if typeof(StopIteration) is 'undefined' then '__break__' else StopIteration
57
57
58
58
59 #### Docco style single line comment (title)
59 #### Docco style single line comment (title)
60
60
61
61
62 # Helper function to escape **RegExp** contents, because JS doesn't have one.
62 # Helper function to escape **RegExp** contents, because JS doesn't have one.
63 escapeRegExp = (string) -> string.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1')
63 escapeRegExp = (string) -> string.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1')
64
64
65
65
66 # Save bytes in the minified (but not gzipped) version:
66 # Save bytes in the minified (but not gzipped) version:
67 ArrayProto = Array.prototype
67 ArrayProto = Array.prototype
68 ObjProto = Object.prototype
68 ObjProto = Object.prototype
69
69
70
70
71 # Create quick reference variables for speed access to core prototypes.
71 # Create quick reference variables for speed access to core prototypes.
72 slice = ArrayProto.slice
72 slice = ArrayProto.slice
73 unshift = ArrayProto.unshift
73 unshift = ArrayProto.unshift
74 toString = ObjProto.toString
74 toString = ObjProto.toString
75 hasOwnProperty = ObjProto.hasOwnProperty
75 hasOwnProperty = ObjProto.hasOwnProperty
76 propertyIsEnumerable = ObjProto.propertyIsEnumerable
76 propertyIsEnumerable = ObjProto.propertyIsEnumerable
77
77
78
78
79 # All **ECMA5** native implementations we hope to use are declared here.
79 # All **ECMA5** native implementations we hope to use are declared here.
80 nativeForEach = ArrayProto.forEach
80 nativeForEach = ArrayProto.forEach
81 nativeMap = ArrayProto.map
81 nativeMap = ArrayProto.map
82 nativeReduce = ArrayProto.reduce
82 nativeReduce = ArrayProto.reduce
83 nativeReduceRight = ArrayProto.reduceRight
83 nativeReduceRight = ArrayProto.reduceRight
84 nativeFilter = ArrayProto.filter
84 nativeFilter = ArrayProto.filter
85 nativeEvery = ArrayProto.every
85 nativeEvery = ArrayProto.every
86 nativeSome = ArrayProto.some
86 nativeSome = ArrayProto.some
87 nativeIndexOf = ArrayProto.indexOf
87 nativeIndexOf = ArrayProto.indexOf
88 nativeLastIndexOf = ArrayProto.lastIndexOf
88 nativeLastIndexOf = ArrayProto.lastIndexOf
89 nativeIsArray = Array.isArray
89 nativeIsArray = Array.isArray
90 nativeKeys = Object.keys
90 nativeKeys = Object.keys
91
91
92
92
93 # Create a safe reference to the Underscore object for use below.
93 # Create a safe reference to the Underscore object for use below.
94 _ = (obj) -> new wrapper(obj)
94 _ = (obj) -> new wrapper(obj)
95
95
96
96
97 # Export the Underscore object for **CommonJS**.
97 # Export the Underscore object for **CommonJS**.
98 if typeof(exports) != 'undefined' then exports._ = _
98 if typeof(exports) != 'undefined' then exports._ = _
99
99
100
100
101 # Export Underscore to global scope.
101 # Export Underscore to global scope.
102 root._ = _
102 root._ = _
103
103
104
104
105 # Current version.
105 # Current version.
106 _.VERSION = '1.1.0'
106 _.VERSION = '1.1.0'
107
107
108
108
109 # Collection Functions
109 # Collection Functions
110 # --------------------
110 # --------------------
111
111
112 # The cornerstone, an **each** implementation.
112 # The cornerstone, an **each** implementation.
113 # Handles objects implementing **forEach**, arrays, and raw objects.
113 # Handles objects implementing **forEach**, arrays, and raw objects.
114 _.each = (obj, iterator, context) ->
114 _.each = (obj, iterator, context) ->
115 try
115 try
116 if nativeForEach and obj.forEach is nativeForEach
116 if nativeForEach and obj.forEach is nativeForEach
117 obj.forEach iterator, context
117 obj.forEach iterator, context
118 else if _.isNumber obj.length
118 else if _.isNumber obj.length
119 iterator.call context, obj[i], i, obj for i in [0...obj.length]
119 iterator.call context, obj[i], i, obj for i in [0...obj.length]
120 else
120 else
121 iterator.call context, val, key, obj for own key, val of obj
121 iterator.call context, val, key, obj for own key, val of obj
122 catch e
122 catch e
123 throw e if e isnt breaker
123 throw e if e isnt breaker
124 obj
124 obj
125
125
126
126
127 # Return the results of applying the iterator to each element. Use JavaScript
127 # Return the results of applying the iterator to each element. Use JavaScript
128 # 1.6's version of **map**, if possible.
128 # 1.6's version of **map**, if possible.
129 _.map = (obj, iterator, context) ->
129 _.map = (obj, iterator, context) ->
130 return obj.map(iterator, context) if nativeMap and obj.map is nativeMap
130 return obj.map(iterator, context) if nativeMap and obj.map is nativeMap
131 results = []
131 results = []
132 _.each obj, (value, index, list) ->
132 _.each obj, (value, index, list) ->
133 results.push iterator.call context, value, index, list
133 results.push iterator.call context, value, index, list
134 results
134 results
135
135
136
136
137 # **Reduce** builds up a single result from a list of values. Also known as
137 # **Reduce** builds up a single result from a list of values. Also known as
138 # **inject**, or **foldl**. Uses JavaScript 1.8's version of **reduce**, if possible.
138 # **inject**, or **foldl**. Uses JavaScript 1.8's version of **reduce**, if possible.
139 _.reduce = (obj, iterator, memo, context) ->
139 _.reduce = (obj, iterator, memo, context) ->
140 if nativeReduce and obj.reduce is nativeReduce
140 if nativeReduce and obj.reduce is nativeReduce
141 iterator = _.bind iterator, context if context
141 iterator = _.bind iterator, context if context
142 return obj.reduce iterator, memo
142 return obj.reduce iterator, memo
143 _.each obj, (value, index, list) ->
143 _.each obj, (value, index, list) ->
144 memo = iterator.call context, memo, value, index, list
144 memo = iterator.call context, memo, value, index, list
145 memo
145 memo
146
146
147
147
148 # The right-associative version of **reduce**, also known as **foldr**. Uses
148 # The right-associative version of **reduce**, also known as **foldr**. Uses
149 # JavaScript 1.8's version of **reduceRight**, if available.
149 # JavaScript 1.8's version of **reduceRight**, if available.
150 _.reduceRight = (obj, iterator, memo, context) ->
150 _.reduceRight = (obj, iterator, memo, context) ->
151 if nativeReduceRight and obj.reduceRight is nativeReduceRight
151 if nativeReduceRight and obj.reduceRight is nativeReduceRight
152 iterator = _.bind iterator, context if context
152 iterator = _.bind iterator, context if context
153 return obj.reduceRight iterator, memo
153 return obj.reduceRight iterator, memo
154 reversed = _.clone(_.toArray(obj)).reverse()
154 reversed = _.clone(_.toArray(obj)).reverse()
155 _.reduce reversed, iterator, memo, context
155 _.reduce reversed, iterator, memo, context
156
156
157
157
158 # Return the first value which passes a truth test.
158 # Return the first value which passes a truth test.
159 _.detect = (obj, iterator, context) ->
159 _.detect = (obj, iterator, context) ->
160 result = null
160 result = null
161 _.each obj, (value, index, list) ->
161 _.each obj, (value, index, list) ->
162 if iterator.call context, value, index, list
162 if iterator.call context, value, index, list
163 result = value
163 result = value
164 _.breakLoop()
164 _.breakLoop()
165 result
165 result
166
166
167
167
168 # Return all the elements that pass a truth test. Use JavaScript 1.6's
168 # Return all the elements that pass a truth test. Use JavaScript 1.6's
169 # **filter**, if it exists.
169 # **filter**, if it exists.
170 _.filter = (obj, iterator, context) ->
170 _.filter = (obj, iterator, context) ->
171 return obj.filter iterator, context if nativeFilter and obj.filter is nativeFilter
171 return obj.filter iterator, context if nativeFilter and obj.filter is nativeFilter
172 results = []
172 results = []
173 _.each obj, (value, index, list) ->
173 _.each obj, (value, index, list) ->
174 results.push value if iterator.call context, value, index, list
174 results.push value if iterator.call context, value, index, list
175 results
175 results
176
176
177
177
178 # Return all the elements for which a truth test fails.
178 # Return all the elements for which a truth test fails.
179 _.reject = (obj, iterator, context) ->
179 _.reject = (obj, iterator, context) ->
180 results = []
180 results = []
181 _.each obj, (value, index, list) ->
181 _.each obj, (value, index, list) ->
182 results.push value if not iterator.call context, value, index, list
182 results.push value if not iterator.call context, value, index, list
183 results
183 results
184
184
185
185
186 # Determine whether all of the elements match a truth test. Delegate to
186 # Determine whether all of the elements match a truth test. Delegate to
187 # JavaScript 1.6's **every**, if it is present.
187 # JavaScript 1.6's **every**, if it is present.
188 _.every = (obj, iterator, context) ->
188 _.every = (obj, iterator, context) ->
189 iterator ||= _.identity
189 iterator ||= _.identity
190 return obj.every iterator, context if nativeEvery and obj.every is nativeEvery
190 return obj.every iterator, context if nativeEvery and obj.every is nativeEvery
191 result = true
191 result = true
192 _.each obj, (value, index, list) ->
192 _.each obj, (value, index, list) ->
193 _.breakLoop() unless (result = result and iterator.call(context, value, index, list))
193 _.breakLoop() unless (result = result and iterator.call(context, value, index, list))
194 result
194 result
195
195
196
196
197 # Determine if at least one element in the object matches a truth test. Use
197 # Determine if at least one element in the object matches a truth test. Use
198 # JavaScript 1.6's **some**, if it exists.
198 # JavaScript 1.6's **some**, if it exists.
199 _.some = (obj, iterator, context) ->
199 _.some = (obj, iterator, context) ->
200 iterator ||= _.identity
200 iterator ||= _.identity
201 return obj.some iterator, context if nativeSome and obj.some is nativeSome
201 return obj.some iterator, context if nativeSome and obj.some is nativeSome
202 result = false
202 result = false
203 _.each obj, (value, index, list) ->
203 _.each obj, (value, index, list) ->
204 _.breakLoop() if (result = iterator.call(context, value, index, list))
204 _.breakLoop() if (result = iterator.call(context, value, index, list))
205 result
205 result
206
206
207
207
208 # Determine if a given value is included in the array or object,
208 # Determine if a given value is included in the array or object,
209 # based on `===`.
209 # based on `===`.
210 _.include = (obj, target) ->
210 _.include = (obj, target) ->
211 return _.indexOf(obj, target) isnt -1 if nativeIndexOf and obj.indexOf is nativeIndexOf
211 return _.indexOf(obj, target) isnt -1 if nativeIndexOf and obj.indexOf is nativeIndexOf
212 return true for own key, val of obj when val is target
212 return true for own key, val of obj when val is target
213 false
213 false
214
214
215
215
216 # Invoke a method with arguments on every item in a collection.
216 # Invoke a method with arguments on every item in a collection.
217 _.invoke = (obj, method) ->
217 _.invoke = (obj, method) ->
218 args = _.rest arguments, 2
218 args = _.rest arguments, 2
219 (if method then val[method] else val).apply(val, args) for val in obj
219 (if method then val[method] else val).apply(val, args) for val in obj
220
220
221
221
222 # Convenience version of a common use case of **map**: fetching a property.
222 # Convenience version of a common use case of **map**: fetching a property.
223 _.pluck = (obj, key) ->
223 _.pluck = (obj, key) ->
224 _.map(obj, (val) -> val[key])
224 _.map(obj, (val) -> val[key])
225
225
226
226
227 # Return the maximum item or (item-based computation).
227 # Return the maximum item or (item-based computation).
228 _.max = (obj, iterator, context) ->
228 _.max = (obj, iterator, context) ->
229 return Math.max.apply(Math, obj) if not iterator and _.isArray(obj)
229 return Math.max.apply(Math, obj) if not iterator and _.isArray(obj)
230 result = computed: -Infinity
230 result = computed: -Infinity
231 _.each obj, (value, index, list) ->
231 _.each obj, (value, index, list) ->
232 computed = if iterator then iterator.call(context, value, index, list) else value
232 computed = if iterator then iterator.call(context, value, index, list) else value
233 computed >= result.computed and (result = {value: value, computed: computed})
233 computed >= result.computed and (result = {value: value, computed: computed})
234 result.value
234 result.value
235
235
236
236
237 # Return the minimum element (or element-based computation).
237 # Return the minimum element (or element-based computation).
238 _.min = (obj, iterator, context) ->
238 _.min = (obj, iterator, context) ->
239 return Math.min.apply(Math, obj) if not iterator and _.isArray(obj)
239 return Math.min.apply(Math, obj) if not iterator and _.isArray(obj)
240 result = computed: Infinity
240 result = computed: Infinity
241 _.each obj, (value, index, list) ->
241 _.each obj, (value, index, list) ->
242 computed = if iterator then iterator.call(context, value, index, list) else value
242 computed = if iterator then iterator.call(context, value, index, list) else value
243 computed < result.computed and (result = {value: value, computed: computed})
243 computed < result.computed and (result = {value: value, computed: computed})
244 result.value
244 result.value
245
245
246
246
247 # Sort the object's values by a criterion produced by an iterator.
247 # Sort the object's values by a criterion produced by an iterator.
248 _.sortBy = (obj, iterator, context) ->
248 _.sortBy = (obj, iterator, context) ->
249 _.pluck(((_.map obj, (value, index, list) ->
249 _.pluck(((_.map obj, (value, index, list) ->
250 {value: value, criteria: iterator.call(context, value, index, list)}
250 {value: value, criteria: iterator.call(context, value, index, list)}
251 ).sort((left, right) ->
251 ).sort((left, right) ->
252 a = left.criteria; b = right.criteria
252 a = left.criteria; b = right.criteria
253 if a < b then -1 else if a > b then 1 else 0
253 if a < b then -1 else if a > b then 1 else 0
254 )), 'value')
254 )), 'value')
255
255
256
256
257 # Use a comparator function to figure out at what index an object should
257 # Use a comparator function to figure out at what index an object should
258 # be inserted so as to maintain order. Uses binary search.
258 # be inserted so as to maintain order. Uses binary search.
259 _.sortedIndex = (array, obj, iterator) ->
259 _.sortedIndex = (array, obj, iterator) ->
260 iterator ||= _.identity
260 iterator ||= _.identity
261 low = 0
261 low = 0
262 high = array.length
262 high = array.length
263 while low < high
263 while low < high
264 mid = (low + high) >> 1
264 mid = (low + high) >> 1
265 if iterator(array[mid]) < iterator(obj) then low = mid + 1 else high = mid
265 if iterator(array[mid]) < iterator(obj) then low = mid + 1 else high = mid
266 low
266 low
267
267
268
268
269 # Convert anything iterable into a real, live array.
269 # Convert anything iterable into a real, live array.
270 _.toArray = (iterable) ->
270 _.toArray = (iterable) ->
271 return [] if (!iterable)
271 return [] if (!iterable)
272 return iterable.toArray() if (iterable.toArray)
272 return iterable.toArray() if (iterable.toArray)
273 return iterable if (_.isArray(iterable))
273 return iterable if (_.isArray(iterable))
274 return slice.call(iterable) if (_.isArguments(iterable))
274 return slice.call(iterable) if (_.isArguments(iterable))
275 _.values(iterable)
275 _.values(iterable)
276
276
277
277
278 # Return the number of elements in an object.
278 # Return the number of elements in an object.
279 _.size = (obj) -> _.toArray(obj).length
279 _.size = (obj) -> _.toArray(obj).length
280
280
281
281
282 # Array Functions
282 # Array Functions
283 # ---------------
283 # ---------------
284
284
285 # Get the first element of an array. Passing `n` will return the first N
285 # Get the first element of an array. Passing `n` will return the first N
286 # values in the array. Aliased as **head**. The `guard` check allows it to work
286 # values in the array. Aliased as **head**. The `guard` check allows it to work
287 # with **map**.
287 # with **map**.
288 _.first = (array, n, guard) ->
288 _.first = (array, n, guard) ->
289 if n and not guard then slice.call(array, 0, n) else array[0]
289 if n and not guard then slice.call(array, 0, n) else array[0]
290
290
291
291
292 # Returns everything but the first entry of the array. Aliased as **tail**.
292 # Returns everything but the first entry of the array. Aliased as **tail**.
293 # Especially useful on the arguments object. Passing an `index` will return
293 # Especially useful on the arguments object. Passing an `index` will return
294 # the rest of the values in the array from that index onward. The `guard`
294 # the rest of the values in the array from that index onward. The `guard`
295 # check allows it to work with **map**.
295 # check allows it to work with **map**.
296 _.rest = (array, index, guard) ->
296 _.rest = (array, index, guard) ->
297 slice.call(array, if _.isUndefined(index) or guard then 1 else index)
297 slice.call(array, if _.isUndefined(index) or guard then 1 else index)
298
298
299
299
300 # Get the last element of an array.
300 # Get the last element of an array.
301 _.last = (array) -> array[array.length - 1]
301 _.last = (array) -> array[array.length - 1]
302
302
303
303
304 # Trim out all falsy values from an array.
304 # Trim out all falsy values from an array.
305 _.compact = (array) -> item for item in array when item
305 _.compact = (array) -> item for item in array when item
306
306
307
307
308 # Return a completely flattened version of an array.
308 # Return a completely flattened version of an array.
309 _.flatten = (array) ->
309 _.flatten = (array) ->
310 _.reduce array, (memo, value) ->
310 _.reduce array, (memo, value) ->
311 return memo.concat(_.flatten(value)) if _.isArray value
311 return memo.concat(_.flatten(value)) if _.isArray value
312 memo.push value
312 memo.push value
313 memo
313 memo
314 , []
314 , []
315
315
316
316
317 # Return a version of the array that does not contain the specified value(s).
317 # Return a version of the array that does not contain the specified value(s).
318 _.without = (array) ->
318 _.without = (array) ->
319 values = _.rest arguments
319 values = _.rest arguments
320 val for val in _.toArray(array) when not _.include values, val
320 val for val in _.toArray(array) when not _.include values, val
321
321
322
322
323 # Produce a duplicate-free version of the array. If the array has already
323 # Produce a duplicate-free version of the array. If the array has already
324 # been sorted, you have the option of using a faster algorithm.
324 # been sorted, you have the option of using a faster algorithm.
325 _.uniq = (array, isSorted) ->
325 _.uniq = (array, isSorted) ->
326 memo = []
326 memo = []
327 for el, i in _.toArray array
327 for el, i in _.toArray array
328 memo.push el if i is 0 || (if isSorted is true then _.last(memo) isnt el else not _.include(memo, el))
328 memo.push el if i is 0 || (if isSorted is true then _.last(memo) isnt el else not _.include(memo, el))
329 memo
329 memo
330
330
331
331
332 # Produce an array that contains every item shared between all the
332 # Produce an array that contains every item shared between all the
333 # passed-in arrays.
333 # passed-in arrays.
334 _.intersect = (array) ->
334 _.intersect = (array) ->
335 rest = _.rest arguments
335 rest = _.rest arguments
336 _.select _.uniq(array), (item) ->
336 _.select _.uniq(array), (item) ->
337 _.all rest, (other) ->
337 _.all rest, (other) ->
338 _.indexOf(other, item) >= 0
338 _.indexOf(other, item) >= 0
339
339
340
340
341 # Zip together multiple lists into a single array -- elements that share
341 # Zip together multiple lists into a single array -- elements that share
342 # an index go together.
342 # an index go together.
343 _.zip = ->
343 _.zip = ->
344 length = _.max _.pluck arguments, 'length'
344 length = _.max _.pluck arguments, 'length'
345 results = new Array length
345 results = new Array length
346 for i in [0...length]
346 for i in [0...length]
347 results[i] = _.pluck arguments, String i
347 results[i] = _.pluck arguments, String i
348 results
348 results
349
349
350
350
351 # If the browser doesn't supply us with **indexOf** (I'm looking at you, MSIE),
351 # If the browser doesn't supply us with **indexOf** (I'm looking at you, MSIE),
352 # we need this function. Return the position of the first occurrence of an
352 # we need this function. Return the position of the first occurrence of an
353 # item in an array, or -1 if the item is not included in the array.
353 # item in an array, or -1 if the item is not included in the array.
354 _.indexOf = (array, item) ->
354 _.indexOf = (array, item) ->
355 return array.indexOf item if nativeIndexOf and array.indexOf is nativeIndexOf
355 return array.indexOf item if nativeIndexOf and array.indexOf is nativeIndexOf
356 i = 0; l = array.length
356 i = 0; l = array.length
357 while l - i
357 while l - i
358 if array[i] is item then return i else i++
358 if array[i] is item then return i else i++
359 -1
359 -1
360
360
361
361
362 # Provide JavaScript 1.6's **lastIndexOf**, delegating to the native function,
362 # Provide JavaScript 1.6's **lastIndexOf**, delegating to the native function,
363 # if possible.
363 # if possible.
364 _.lastIndexOf = (array, item) ->
364 _.lastIndexOf = (array, item) ->
365 return array.lastIndexOf(item) if nativeLastIndexOf and array.lastIndexOf is nativeLastIndexOf
365 return array.lastIndexOf(item) if nativeLastIndexOf and array.lastIndexOf is nativeLastIndexOf
366 i = array.length
366 i = array.length
367 while i
367 while i
368 if array[i] is item then return i else i--
368 if array[i] is item then return i else i--
369 -1
369 -1
370
370
371
371
372 # Generate an integer Array containing an arithmetic progression. A port of
372 # Generate an integer Array containing an arithmetic progression. A port of
373 # [the native Python **range** function](http://docs.python.org/library/functions.html#range).
373 # [the native Python **range** function](http://docs.python.org/library/functions.html#range).
374 _.range = (start, stop, step) ->
374 _.range = (start, stop, step) ->
375 a = arguments
375 a = arguments
376 solo = a.length <= 1
376 solo = a.length <= 1
377 i = start = if solo then 0 else a[0]
377 i = start = if solo then 0 else a[0]
378 stop = if solo then a[0] else a[1]
378 stop = if solo then a[0] else a[1]
379 step = a[2] or 1
379 step = a[2] or 1
380 len = Math.ceil((stop - start) / step)
380 len = Math.ceil((stop - start) / step)
381 return [] if len <= 0
381 return [] if len <= 0
382 range = new Array len
382 range = new Array len
383 idx = 0
383 idx = 0
384 loop
384 loop
385 return range if (if step > 0 then i - stop else stop - i) >= 0
385 return range if (if step > 0 then i - stop else stop - i) >= 0
386 range[idx] = i
386 range[idx] = i
387 idx++
387 idx++
388 i+= step
388 i+= step
389
389
390
390
391 # Function Functions
391 # Function Functions
392 # ------------------
392 # ------------------
393
393
394 # Create a function bound to a given object (assigning `this`, and arguments,
394 # Create a function bound to a given object (assigning `this`, and arguments,
395 # optionally). Binding with arguments is also known as **curry**.
395 # optionally). Binding with arguments is also known as **curry**.
396 _.bind = (func, obj) ->
396 _.bind = (func, obj) ->
397 args = _.rest arguments, 2
397 args = _.rest arguments, 2
398 -> func.apply obj or root, args.concat arguments
398 -> func.apply obj or root, args.concat arguments
399
399
400
400
401 # Bind all of an object's methods to that object. Useful for ensuring that
401 # Bind all of an object's methods to that object. Useful for ensuring that
402 # all callbacks defined on an object belong to it.
402 # all callbacks defined on an object belong to it.
403 _.bindAll = (obj) ->
403 _.bindAll = (obj) ->
404 funcs = if arguments.length > 1 then _.rest(arguments) else _.functions(obj)
404 funcs = if arguments.length > 1 then _.rest(arguments) else _.functions(obj)
405 _.each funcs, (f) -> obj[f] = _.bind obj[f], obj
405 _.each funcs, (f) -> obj[f] = _.bind obj[f], obj
406 obj
406 obj
407
407
408
408
409 # Delays a function for the given number of milliseconds, and then calls
409 # Delays a function for the given number of milliseconds, and then calls
410 # it with the arguments supplied.
410 # it with the arguments supplied.
411 _.delay = (func, wait) ->
411 _.delay = (func, wait) ->
412 args = _.rest arguments, 2
412 args = _.rest arguments, 2
413 setTimeout((-> func.apply(func, args)), wait)
413 setTimeout((-> func.apply(func, args)), wait)
414
414
415
415
416 # Memoize an expensive function by storing its results.
416 # Memoize an expensive function by storing its results.
417 _.memoize = (func, hasher) ->
417 _.memoize = (func, hasher) ->
418 memo = {}
418 memo = {}
419 hasher or= _.identity
419 hasher or= _.identity
420 ->
420 ->
421 key = hasher.apply this, arguments
421 key = hasher.apply this, arguments
422 return memo[key] if key of memo
422 return memo[key] if key of memo
423 memo[key] = func.apply this, arguments
423 memo[key] = func.apply this, arguments
424
424
425
425
426 # Defers a function, scheduling it to run after the current call stack has
426 # Defers a function, scheduling it to run after the current call stack has
427 # cleared.
427 # cleared.
428 _.defer = (func) ->
428 _.defer = (func) ->
429 _.delay.apply _, [func, 1].concat _.rest arguments
429 _.delay.apply _, [func, 1].concat _.rest arguments
430
430
431
431
432 # Returns the first function passed as an argument to the second,
432 # Returns the first function passed as an argument to the second,
433 # allowing you to adjust arguments, run code before and after, and
433 # allowing you to adjust arguments, run code before and after, and
434 # conditionally execute the original function.
434 # conditionally execute the original function.
435 _.wrap = (func, wrapper) ->
435 _.wrap = (func, wrapper) ->
436 -> wrapper.apply wrapper, [func].concat arguments
436 -> wrapper.apply wrapper, [func].concat arguments
437
437
438
438
439 # Returns a function that is the composition of a list of functions, each
439 # Returns a function that is the composition of a list of functions, each
440 # consuming the return value of the function that follows.
440 # consuming the return value of the function that follows.
441 _.compose = ->
441 _.compose = ->
442 funcs = arguments
442 funcs = arguments
443 ->
443 ->
444 args = arguments
444 args = arguments
445 for i in [funcs.length - 1..0] by -1
445 for i in [funcs.length - 1..0] by -1
446 args = [funcs[i].apply(this, args)]
446 args = [funcs[i].apply(this, args)]
447 args[0]
447 args[0]
448
448
449
449
450 # Object Functions
450 # Object Functions
451 # ----------------
451 # ----------------
452
452
453 # Retrieve the names of an object's properties.
453 # Retrieve the names of an object's properties.
454 _.keys = nativeKeys or (obj) ->
454 _.keys = nativeKeys or (obj) ->
455 return _.range 0, obj.length if _.isArray(obj)
455 return _.range 0, obj.length if _.isArray(obj)
456 key for key, val of obj
456 key for key, val of obj
457
457
458
458
459 # Retrieve the values of an object's properties.
459 # Retrieve the values of an object's properties.
460 _.values = (obj) ->
460 _.values = (obj) ->
461 _.map obj, _.identity
461 _.map obj, _.identity
462
462
463
463
464 # Return a sorted list of the function names available in Underscore.
464 # Return a sorted list of the function names available in Underscore.
465 _.functions = (obj) ->
465 _.functions = (obj) ->
466 _.filter(_.keys(obj), (key) -> _.isFunction(obj[key])).sort()
466 _.filter(_.keys(obj), (key) -> _.isFunction(obj[key])).sort()
467
467
468
468
469 # Extend a given object with all of the properties in a source object.
469 # Extend a given object with all of the properties in a source object.
470 _.extend = (obj) ->
470 _.extend = (obj) ->
471 for source in _.rest(arguments)
471 for source in _.rest(arguments)
472 obj[key] = val for key, val of source
472 obj[key] = val for key, val of source
473 obj
473 obj
474
474
475
475
476 # Create a (shallow-cloned) duplicate of an object.
476 # Create a (shallow-cloned) duplicate of an object.
477 _.clone = (obj) ->
477 _.clone = (obj) ->
478 return obj.slice 0 if _.isArray obj
478 return obj.slice 0 if _.isArray obj
479 _.extend {}, obj
479 _.extend {}, obj
480
480
481
481
482 # Invokes interceptor with the obj, and then returns obj.
482 # Invokes interceptor with the obj, and then returns obj.
483 # The primary purpose of this method is to "tap into" a method chain,
483 # The primary purpose of this method is to "tap into" a method chain,
484 # in order to perform operations on intermediate results within
484 # in order to perform operations on intermediate results within
485 the chain.
485 the chain.
486 _.tap = (obj, interceptor) ->
486 _.tap = (obj, interceptor) ->
487 interceptor obj
487 interceptor obj
488 obj
488 obj
489
489
490
490
491 # Perform a deep comparison to check if two objects are equal.
491 # Perform a deep comparison to check if two objects are equal.
492 _.isEqual = (a, b) ->
492 _.isEqual = (a, b) ->
493 # Check object identity.
493 # Check object identity.
494 return true if a is b
494 return true if a is b
495 # Different types?
495 # Different types?
496 atype = typeof(a); btype = typeof(b)
496 atype = typeof(a); btype = typeof(b)
497 return false if atype isnt btype
497 return false if atype isnt btype
498 # Basic equality test (watch out for coercions).
498 # Basic equality test (watch out for coercions).
499 return true if `a == b`
499 return true if `a == b`
500 # One is falsy and the other truthy.
500 # One is falsy and the other truthy.
501 return false if (!a and b) or (a and !b)
501 return false if (!a and b) or (a and !b)
502 # One of them implements an `isEqual()`?
502 # One of them implements an `isEqual()`?
503 return a.isEqual(b) if a.isEqual
503 return a.isEqual(b) if a.isEqual
504 # Check dates' integer values.
504 # Check dates' integer values.
505 return a.getTime() is b.getTime() if _.isDate(a) and _.isDate(b)
505 return a.getTime() is b.getTime() if _.isDate(a) and _.isDate(b)
506 # Both are NaN?
506 # Both are NaN?
507 return false if _.isNaN(a) and _.isNaN(b)
507 return false if _.isNaN(a) and _.isNaN(b)
508 # Compare regular expressions.
508 # Compare regular expressions.
509 if _.isRegExp(a) and _.isRegExp(b)
509 if _.isRegExp(a) and _.isRegExp(b)
510 return a.source is b.source and
510 return a.source is b.source and
511 a.global is b.global and
511 a.global is b.global and
512 a.ignoreCase is b.ignoreCase and
512 a.ignoreCase is b.ignoreCase and
513 a.multiline is b.multiline
513 a.multiline is b.multiline
514 # If a is not an object by this point, we can't handle it.
514 # If a is not an object by this point, we can't handle it.
515 return false if atype isnt 'object'
515 return false if atype isnt 'object'
516 # Check for different array lengths before comparing contents.
516 # Check for different array lengths before comparing contents.
517 return false if a.length and (a.length isnt b.length)
517 return false if a.length and (a.length isnt b.length)
518 # Nothing else worked, deep compare the contents.
518 # Nothing else worked, deep compare the contents.
519 aKeys = _.keys(a); bKeys = _.keys(b)
519 aKeys = _.keys(a); bKeys = _.keys(b)
520 # Different object sizes?
520 # Different object sizes?
521 return false if aKeys.length isnt bKeys.length
521 return false if aKeys.length isnt bKeys.length
522 # Recursive comparison of contents.
522 # Recursive comparison of contents.
523 return false for key, val of a when !(key of b) or !_.isEqual(val, b[key])
523 return false for key, val of a when !(key of b) or !_.isEqual(val, b[key])
524 true
524 true
525
525
526
526
527 # Is a given array or object empty?
527 # Is a given array or object empty?
528 _.isEmpty = (obj) ->
528 _.isEmpty = (obj) ->
529 return obj.length is 0 if _.isArray(obj) or _.isString(obj)
529 return obj.length is 0 if _.isArray(obj) or _.isString(obj)
530 return false for own key of obj
530 return false for own key of obj
531 true
531 true
532
532
533
533
534 # Is a given value a DOM element?
534 # Is a given value a DOM element?
535 _.isElement = (obj) -> obj and obj.nodeType is 1
535 _.isElement = (obj) -> obj and obj.nodeType is 1
536
536
537
537
538 # Is a given value an array?
538 # Is a given value an array?
539 _.isArray = nativeIsArray or (obj) -> !!(obj and obj.concat and obj.unshift and not obj.callee)
539 _.isArray = nativeIsArray or (obj) -> !!(obj and obj.concat and obj.unshift and not obj.callee)
540
540
541
541
542 # Is a given variable an arguments object?
542 # Is a given variable an arguments object?
543 _.isArguments = (obj) -> obj and obj.callee
543 _.isArguments = (obj) -> obj and obj.callee
544
544
545
545
546 # Is the given value a function?
546 # Is the given value a function?
547 _.isFunction = (obj) -> !!(obj and obj.constructor and obj.call and obj.apply)
547 _.isFunction = (obj) -> !!(obj and obj.constructor and obj.call and obj.apply)
548
548
549
549
550 # Is the given value a string?
550 # Is the given value a string?
551 _.isString = (obj) -> !!(obj is '' or (obj and obj.charCodeAt and obj.substr))
551 _.isString = (obj) -> !!(obj is '' or (obj and obj.charCodeAt and obj.substr))
552
552
553
553
554 # Is a given value a number?
554 # Is a given value a number?
555 _.isNumber = (obj) -> (obj is +obj) or toString.call(obj) is '[object Number]'
555 _.isNumber = (obj) -> (obj is +obj) or toString.call(obj) is '[object Number]'
556
556
557
557
558 # Is a given value a boolean?
558 # Is a given value a boolean?
559 _.isBoolean = (obj) -> obj is true or obj is false
559 _.isBoolean = (obj) -> obj is true or obj is false
560
560
561
561
562 # Is a given value a Date?
562 # Is a given value a Date?
563 _.isDate = (obj) -> !!(obj and obj.getTimezoneOffset and obj.setUTCFullYear)
563 _.isDate = (obj) -> !!(obj and obj.getTimezoneOffset and obj.setUTCFullYear)
564
564
565
565
566 # Is the given value a regular expression?
566 # Is the given value a regular expression?
567 _.isRegExp = (obj) -> !!(obj and obj.exec and (obj.ignoreCase or obj.ignoreCase is false))
567 _.isRegExp = (obj) -> !!(obj and obj.exec and (obj.ignoreCase or obj.ignoreCase is false))
568
568
569
569
570 # Is the given value NaN -- this one is interesting. `NaN != NaN`, and
570 # Is the given value NaN -- this one is interesting. `NaN != NaN`, and
571 # `isNaN(undefined) == true`, so we make sure it's a number first.
571 # `isNaN(undefined) == true`, so we make sure it's a number first.
572 _.isNaN = (obj) -> _.isNumber(obj) and window.isNaN(obj)
572 _.isNaN = (obj) -> _.isNumber(obj) and window.isNaN(obj)
573
573
574
574
575 # Is a given value equal to null?
575 # Is a given value equal to null?
576 _.isNull = (obj) -> obj is null
576 _.isNull = (obj) -> obj is null
577
577
578
578
579 # Is a given variable undefined?
579 # Is a given variable undefined?
580 _.isUndefined = (obj) -> typeof obj is 'undefined'
580 _.isUndefined = (obj) -> typeof obj is 'undefined'
581
581
582
582
583 # Utility Functions
583 # Utility Functions
584 # -----------------
584 # -----------------
585
585
586 # Run Underscore.js in noConflict mode, returning the `_` variable to its
586 # Run Underscore.js in noConflict mode, returning the `_` variable to its
587 # previous owner. Returns a reference to the Underscore object.
587 # previous owner. Returns a reference to the Underscore object.
588 _.noConflict = ->
588 _.noConflict = ->
589 root._ = previousUnderscore
589 root._ = previousUnderscore
590 this
590 this
591
591
592
592
593 # Keep the identity function around for default iterators.
593 # Keep the identity function around for default iterators.
594 _.identity = (value) -> value
594 _.identity = (value) -> value
595
595
596
596
597 # Run a function `n` times.
597 # Run a function `n` times.
598 _.times = (n, iterator, context) ->
598 _.times = (n, iterator, context) ->
599 iterator.call context, i for i in [0...n]
599 iterator.call context, i for i in [0...n]
600
600
601
601
602 # Break out of the middle of an iteration.
602 # Break out of the middle of an iteration.
603 _.breakLoop = -> throw breaker
603 _.breakLoop = -> throw breaker
604
604
605
605
606 # Add your own custom functions to the Underscore object, ensuring that
606 # Add your own custom functions to the Underscore object, ensuring that
607 # they're correctly added to the OOP wrapper as well.
607 # they're correctly added to the OOP wrapper as well.
608 _.mixin = (obj) ->
608 _.mixin = (obj) ->
609 for name in _.functions(obj)
609 for name in _.functions(obj)
610 addToWrapper name, _[name] = obj[name]
610 addToWrapper name, _[name] = obj[name]
611
611
612
612
613 # Generate a unique integer id (unique within the entire client session).
613 # Generate a unique integer id (unique within the entire client session).
614 # Useful for temporary DOM ids.
614 # Useful for temporary DOM ids.
615 idCounter = 0
615 idCounter = 0
616 _.uniqueId = (prefix) ->
616 _.uniqueId = (prefix) ->
617 (prefix or '') + idCounter++
617 (prefix or '') + idCounter++
618
618
619
619
620 # By default, Underscore uses **ERB**-style template delimiters, change the
620 # By default, Underscore uses **ERB**-style template delimiters, change the
621 # following template settings to use alternative delimiters.
621 # following template settings to use alternative delimiters.
622 _.templateSettings = {
622 _.templateSettings = {
623 start: '<%'
623 start: '<%'
624 end: '%>'
624 end: '%>'
625 interpolate: /<%=(.+?)%>/g
625 interpolate: /<%=(.+?)%>/g
626 }
626 }
627
627
628
628
629 # JavaScript templating a-la **ERB**, pilfered from John Resig's
629 # JavaScript templating a-la **ERB**, pilfered from John Resig's
630 # *Secrets of the JavaScript Ninja*, page 83.
630 # *Secrets of the JavaScript Ninja*, page 83.
631 # Single-quote fix from Rick Strahl.
631 # Single-quote fix from Rick Strahl.
632 # With alterations for arbitrary delimiters, and to preserve whitespace.
632 # With alterations for arbitrary delimiters, and to preserve whitespace.
633 _.template = (str, data) ->
633 _.template = (str, data) ->
634 c = _.templateSettings
634 c = _.templateSettings
635 endMatch = new RegExp("'(?=[^"+c.end.substr(0, 1)+"]*"+escapeRegExp(c.end)+")","g")
635 endMatch = new RegExp("'(?=[^"+c.end.substr(0, 1)+"]*"+escapeRegExp(c.end)+")","g")
636 fn = new Function 'obj',
636 fn = new Function 'obj',
637 'var p=[],print=function(){p.push.apply(p,arguments);};' +
637 'var p=[],print=function(){p.push.apply(p,arguments);};' +
638 'with(obj||{}){p.push(\'' +
638 'with(obj||{}){p.push(\'' +
639 str.replace(/\r/g, '\\r')
639 str.replace(/\r/g, '\\r')
640 .replace(/\n/g, '\\n')
640 .replace(/\n/g, '\\n')
641 .replace(/\t/g, '\\t')
641 .replace(/\t/g, '\\t')
642 .replace(endMatch,"���")
642 .replace(endMatch,"���")
643 .split("'").join("\\'")
643 .split("'").join("\\'")
644 .split("���").join("'")
644 .split("���").join("'")
645 .replace(c.interpolate, "',$1,'")
645 .replace(c.interpolate, "',$1,'")
646 .split(c.start).join("');")
646 .split(c.start).join("');")
647 .split(c.end).join("p.push('") +
647 .split(c.end).join("p.push('") +
648 "');}return p.join('');"
648 "');}return p.join('');"
649 if data then fn(data) else fn
649 if data then fn(data) else fn
650
650
651
651
652 # Aliases
652 # Aliases
653 # -------
653 # -------
654
654
655 _.forEach = _.each
655 _.forEach = _.each
656 _.foldl = _.inject = _.reduce
656 _.foldl = _.inject = _.reduce
657 _.foldr = _.reduceRight
657 _.foldr = _.reduceRight
658 _.select = _.filter
658 _.select = _.filter
659 _.all = _.every
659 _.all = _.every
660 _.any = _.some
660 _.any = _.some
661 _.contains = _.include
661 _.contains = _.include
662 _.head = _.first
662 _.head = _.first
663 _.tail = _.rest
663 _.tail = _.rest
664 _.methods = _.functions
664 _.methods = _.functions
665
665
666
666
667 # Setup the OOP Wrapper
667 # Setup the OOP Wrapper
668 # ---------------------
668 # ---------------------
669
669
670 # If Underscore is called as a function, it returns a wrapped object that
670 # If Underscore is called as a function, it returns a wrapped object that
671 # can be used OO-style. This wrapper holds altered versions of all the
671 # can be used OO-style. This wrapper holds altered versions of all the
672 # underscore functions. Wrapped objects may be chained.
672 # underscore functions. Wrapped objects may be chained.
673 wrapper = (obj) ->
673 wrapper = (obj) ->
674 this._wrapped = obj
674 this._wrapped = obj
675 this
675 this
676
676
677
677
678 # Helper function to continue chaining intermediate results.
678 # Helper function to continue chaining intermediate results.
679 result = (obj, chain) ->
679 result = (obj, chain) ->
680 if chain then _(obj).chain() else obj
680 if chain then _(obj).chain() else obj
681
681
682
682
683 # A method to easily add functions to the OOP wrapper.
683 # A method to easily add functions to the OOP wrapper.
684 addToWrapper = (name, func) ->
684 addToWrapper = (name, func) ->
685 wrapper.prototype[name] = ->
685 wrapper.prototype[name] = ->
686 args = _.toArray arguments
686 args = _.toArray arguments
687 unshift.call args, this._wrapped
687 unshift.call args, this._wrapped
688 result func.apply(_, args), this._chain
688 result func.apply(_, args), this._chain
689
689
690
690
691 # Add all ofthe Underscore functions to the wrapper object.
691 # Add all ofthe Underscore functions to the wrapper object.
692 _.mixin _
692 _.mixin _
693
693
694
694
695 # Add all mutator Array functions to the wrapper.
695 # Add all mutator Array functions to the wrapper.
696 _.each ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], (name) ->
696 _.each ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], (name) ->
697 method = Array.prototype[name]
697 method = Array.prototype[name]
698 wrapper.prototype[name] = ->
698 wrapper.prototype[name] = ->
699 method.apply(this._wrapped, arguments)
699 method.apply(this._wrapped, arguments)
700 result(this._wrapped, this._chain)
700 result(this._wrapped, this._chain)
701
701
702
702
703 # Add all accessor Array functions to the wrapper.
703 # Add all accessor Array functions to the wrapper.
704 _.each ['concat', 'join', 'slice'], (name) ->
704 _.each ['concat', 'join', 'slice'], (name) ->
705 method = Array.prototype[name]
705 method = Array.prototype[name]
706 wrapper.prototype[name] = ->
706 wrapper.prototype[name] = ->
707 result(method.apply(this._wrapped, arguments), this._chain)
707 result(method.apply(this._wrapped, arguments), this._chain)
708
708
709
709
710 # Start chaining a wrapped Underscore object.
710 # Start chaining a wrapped Underscore object.
711 wrapper::chain = ->
711 wrapper::chain = ->
712 this._chain = true
712 this._chain = true
713 this
713 this
714
714
715
715
716 # Extracts the result from a wrapped and chained object.
716 # Extracts the result from a wrapped and chained object.
717 wrapper::value = -> this._wrapped
717 wrapper::value = -> this._wrapped
718 </textarea></form>
718 </textarea></form>
719 <script>
719 <script>
720 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
720 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
721 </script>
721 </script>
722
722
723 <p><strong>MIME types defined:</strong> <code>text/x-coffeescript</code>.</p>
723 <p><strong>MIME types defined:</strong> <code>text/x-coffeescript</code>.</p>
724
724
725 <p>The CoffeeScript mode was written by Jeff Pickhardt (<a href="LICENSE">license</a>).</p>
725 <p>The CoffeeScript mode was written by Jeff Pickhardt (<a href="LICENSE">license</a>).</p>
726
726
727 </body>
727 </body>
728 </html>
728 </html>
@@ -1,105 +1,105 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: Diff mode</title>
5 <title>CodeMirror: Diff mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="diff.js"></script>
8 <script src="diff.js"></script>
9 <style>
9 <style>
10 .CodeMirror {border-top: 1px solid #ddd; border-bottom: 1px solid #ddd;}
10 .CodeMirror {border-top: 1px solid #ddd; border-bottom: 1px solid #ddd;}
11 span.cm-meta {color: #a0b !important;}
11 span.cm-meta {color: #a0b !important;}
12 span.cm-error { background-color: black; opacity: 0.4;}
12 span.cm-error { background-color: black; opacity: 0.4;}
13 span.cm-error.cm-string { background-color: red; }
13 span.cm-error.cm-string { background-color: red; }
14 span.cm-error.cm-tag { background-color: #2b2; }
14 span.cm-error.cm-tag { background-color: #2b2; }
15 </style>
15 </style>
16 <link rel="stylesheet" href="../../doc/docs.css">
16 <link rel="stylesheet" href="../../doc/docs.css">
17 </head>
17 </head>
18 <body>
18 <body>
19 <h1>CodeMirror: Diff mode</h1>
19 <h1>CodeMirror: Diff mode</h1>
20 <form><textarea id="code" name="code">
20 <form><textarea id="code" name="code">
21 diff --git a/index.html b/index.html
21 diff --git a/index.html b/index.html
22 index c1d9156..7764744 100644
22 index c1d9156..7764744 100644
23 --- a/index.html
23 --- a/index.html
24 +++ b/index.html
24 +++ b/index.html
25 @@ -95,7 +95,8 @@ StringStream.prototype = {
25 @@ -95,7 +95,8 @@ StringStream.prototype = {
26 <script>
26 <script>
27 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
27 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
28 lineNumbers: true,
28 lineNumbers: true,
29 - autoMatchBrackets: true
29 - autoMatchBrackets: true
30 + autoMatchBrackets: true,
30 + autoMatchBrackets: true,
31 + onGutterClick: function(x){console.log(x);}
31 + onGutterClick: function(x){console.log(x);}
32 });
32 });
33 </script>
33 </script>
34 </body>
34 </body>
35 diff --git a/lib/codemirror.js b/lib/codemirror.js
35 diff --git a/lib/codemirror.js b/lib/codemirror.js
36 index 04646a9..9a39cc7 100644
36 index 04646a9..9a39cc7 100644
37 --- a/lib/codemirror.js
37 --- a/lib/codemirror.js
38 +++ b/lib/codemirror.js
38 +++ b/lib/codemirror.js
39 @@ -399,10 +399,16 @@ var CodeMirror = (function() {
39 @@ -399,10 +399,16 @@ var CodeMirror = (function() {
40 }
40 }
41
41
42 function onMouseDown(e) {
42 function onMouseDown(e) {
43 - var start = posFromMouse(e), last = start;
43 - var start = posFromMouse(e), last = start;
44 + var start = posFromMouse(e), last = start, target = e.target();
44 + var start = posFromMouse(e), last = start, target = e.target();
45 if (!start) return;
45 if (!start) return;
46 setCursor(start.line, start.ch, false);
46 setCursor(start.line, start.ch, false);
47 if (e.button() != 1) return;
47 if (e.button() != 1) return;
48 + if (target.parentNode == gutter) {
48 + if (target.parentNode == gutter) {
49 + if (options.onGutterClick)
49 + if (options.onGutterClick)
50 + options.onGutterClick(indexOf(gutter.childNodes, target) + showingFrom);
50 + options.onGutterClick(indexOf(gutter.childNodes, target) + showingFrom);
51 + return;
51 + return;
52 + }
52 + }
53 +
53 +
54 if (!focused) onFocus();
54 if (!focused) onFocus();
55
55
56 e.stop();
56 e.stop();
57 @@ -808,7 +814,7 @@ var CodeMirror = (function() {
57 @@ -808,7 +814,7 @@ var CodeMirror = (function() {
58 for (var i = showingFrom; i < showingTo; ++i) {
58 for (var i = showingFrom; i < showingTo; ++i) {
59 var marker = lines[i].gutterMarker;
59 var marker = lines[i].gutterMarker;
60 if (marker) html.push('<div class="' + marker.style + '">' + htmlEscape(marker.text) + '</div>');
60 if (marker) html.push('<div class="' + marker.style + '">' + htmlEscape(marker.text) + '</div>');
61 - else html.push("<div>" + (options.lineNumbers ? i + 1 : "\u00a0") + "</div>");
61 - else html.push("<div>" + (options.lineNumbers ? i + 1 : "\u00a0") + "</div>");
62 + else html.push("<div>" + (options.lineNumbers ? i + options.firstLineNumber : "\u00a0") + "</div>");
62 + else html.push("<div>" + (options.lineNumbers ? i + options.firstLineNumber : "\u00a0") + "</div>");
63 }
63 }
64 gutter.style.display = "none"; // TODO test whether this actually helps
64 gutter.style.display = "none"; // TODO test whether this actually helps
65 gutter.innerHTML = html.join("");
65 gutter.innerHTML = html.join("");
66 @@ -1371,10 +1377,8 @@ var CodeMirror = (function() {
66 @@ -1371,10 +1377,8 @@ var CodeMirror = (function() {
67 if (option == "parser") setParser(value);
67 if (option == "parser") setParser(value);
68 else if (option === "lineNumbers") setLineNumbers(value);
68 else if (option === "lineNumbers") setLineNumbers(value);
69 else if (option === "gutter") setGutter(value);
69 else if (option === "gutter") setGutter(value);
70 - else if (option === "readOnly") options.readOnly = value;
70 - else if (option === "readOnly") options.readOnly = value;
71 - else if (option === "indentUnit") {options.indentUnit = indentUnit = value; setParser(options.parser);}
71 - else if (option === "indentUnit") {options.indentUnit = indentUnit = value; setParser(options.parser);}
72 - else if (/^(?:enterMode|tabMode|indentWithTabs|readOnly|autoMatchBrackets|undoDepth)$/.test(option)) options[option] = value;
72 - else if (/^(?:enterMode|tabMode|indentWithTabs|readOnly|autoMatchBrackets|undoDepth)$/.test(option)) options[option] = value;
73 - else throw new Error("Can't set option " + option);
73 - else throw new Error("Can't set option " + option);
74 + else if (option === "indentUnit") {options.indentUnit = value; setParser(options.parser);}
74 + else if (option === "indentUnit") {options.indentUnit = value; setParser(options.parser);}
75 + else options[option] = value;
75 + else options[option] = value;
76 },
76 },
77 cursorCoords: cursorCoords,
77 cursorCoords: cursorCoords,
78 undo: operation(undo),
78 undo: operation(undo),
79 @@ -1402,7 +1406,8 @@ var CodeMirror = (function() {
79 @@ -1402,7 +1406,8 @@ var CodeMirror = (function() {
80 replaceRange: operation(replaceRange),
80 replaceRange: operation(replaceRange),
81
81
82 operation: function(f){return operation(f)();},
82 operation: function(f){return operation(f)();},
83 - refresh: function(){updateDisplay([{from: 0, to: lines.length}]);}
83 - refresh: function(){updateDisplay([{from: 0, to: lines.length}]);}
84 + refresh: function(){updateDisplay([{from: 0, to: lines.length}]);},
84 + refresh: function(){updateDisplay([{from: 0, to: lines.length}]);},
85 + getInputField: function(){return input;}
85 + getInputField: function(){return input;}
86 };
86 };
87 return instance;
87 return instance;
88 }
88 }
89 @@ -1420,6 +1425,7 @@ var CodeMirror = (function() {
89 @@ -1420,6 +1425,7 @@ var CodeMirror = (function() {
90 readOnly: false,
90 readOnly: false,
91 onChange: null,
91 onChange: null,
92 onCursorActivity: null,
92 onCursorActivity: null,
93 + onGutterClick: null,
93 + onGutterClick: null,
94 autoMatchBrackets: false,
94 autoMatchBrackets: false,
95 workTime: 200,
95 workTime: 200,
96 workDelay: 300,
96 workDelay: 300,
97 </textarea></form>
97 </textarea></form>
98 <script>
98 <script>
99 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
99 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
100 </script>
100 </script>
101
101
102 <p><strong>MIME types defined:</strong> <code>text/x-diff</code>.</p>
102 <p><strong>MIME types defined:</strong> <code>text/x-diff</code>.</p>
103
103
104 </body>
104 </body>
105 </html>
105 </html>
@@ -1,39 +1,39 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <title>CodeMirror: ECL mode</title>
4 <title>CodeMirror: ECL mode</title>
5 <link rel="stylesheet" href="../../lib/codemirror.css">
5 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <script src="../../lib/codemirror.js"></script>
6 <script src="../../lib/codemirror.js"></script>
7 <script src="ecl.js"></script>
7 <script src="ecl.js"></script>
8 <link rel="stylesheet" href="../../doc/docs.css">
8 <link rel="stylesheet" href="../../doc/docs.css">
9 <style>.CodeMirror {border: 1px solid black;}</style>
9 <style>.CodeMirror {border: 1px solid black;}</style>
10 </head>
10 </head>
11 <body>
11 <body>
12 <h1>CodeMirror: ECL mode</h1>
12 <h1>CodeMirror: ECL mode</h1>
13 <form><textarea id="code" name="code">
13 <form><textarea id="code" name="code">
14 /*
14 /*
15 sample useless code to demonstrate ecl syntax highlighting
15 sample useless code to demonstrate ecl syntax highlighting
16 this is a multiline comment!
16 this is a multiline comment!
17 */
17 */
18
18
19 // this is a singleline comment!
19 // this is a singleline comment!
20
20
21 import ut;
21 import ut;
22 r :=
22 r :=
23 record
23 record
24 string22 s1 := '123';
24 string22 s1 := '123';
25 integer4 i1 := 123;
25 integer4 i1 := 123;
26 end;
26 end;
27 #option('tmp', true);
27 #option('tmp', true);
28 d := dataset('tmp::qb', r, thor);
28 d := dataset('tmp::qb', r, thor);
29 output(d);
29 output(d);
30 </textarea></form>
30 </textarea></form>
31 <script>
31 <script>
32 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
32 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
33 </script>
33 </script>
34
34
35 <p>Based on CodeMirror's clike mode. For more information see <a href="http://hpccsystems.com">HPCC Systems</a> web site.</p>
35 <p>Based on CodeMirror's clike mode. For more information see <a href="http://hpccsystems.com">HPCC Systems</a> web site.</p>
36 <p><strong>MIME types defined:</strong> <code>text/x-ecl</code>.</p>
36 <p><strong>MIME types defined:</strong> <code>text/x-ecl</code>.</p>
37
37
38 </body>
38 </body>
39 </html>
39 </html>
@@ -1,64 +1,64 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: Erlang mode</title>
5 <title>CodeMirror: Erlang mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="../../addon/edit/matchbrackets.js"></script>
8 <script src="../../addon/edit/matchbrackets.js"></script>
9 <script src="erlang.js"></script>
9 <script src="erlang.js"></script>
10 <link rel="stylesheet" href="../../theme/erlang-dark.css">
10 <link rel="stylesheet" href="../../theme/erlang-dark.css">
11 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
11 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
12 <link rel="stylesheet" href="../../doc/docs.css">
12 <link rel="stylesheet" href="../../doc/docs.css">
13 </head>
13 </head>
14 <body>
14 <body>
15 <h1>CodeMirror: Erlang mode</h1>
15 <h1>CodeMirror: Erlang mode</h1>
16
16
17 <form><textarea id="code" name="code">
17 <form><textarea id="code" name="code">
18 %% -*- mode: erlang; erlang-indent-level: 2 -*-
18 %% -*- mode: erlang; erlang-indent-level: 2 -*-
19 %%% Created : 7 May 2012 by mats cronqvist <masse@klarna.com>
19 %%% Created : 7 May 2012 by mats cronqvist <masse@klarna.com>
20
20
21 %% @doc
21 %% @doc
22 %% Demonstrates how to print a record.
22 %% Demonstrates how to print a record.
23 %% @end
23 %% @end
24
24
25 -module('ex').
25 -module('ex').
26 -author('mats cronqvist').
26 -author('mats cronqvist').
27 -export([demo/0,
27 -export([demo/0,
28 rec_info/1]).
28 rec_info/1]).
29
29
30 -record(demo,{a="One",b="Two",c="Three",d="Four"}).
30 -record(demo,{a="One",b="Two",c="Three",d="Four"}).
31
31
32 rec_info(demo) -> record_info(fields,demo).
32 rec_info(demo) -> record_info(fields,demo).
33
33
34 demo() -> expand_recs(?MODULE,#demo{a="A",b="BB"}).
34 demo() -> expand_recs(?MODULE,#demo{a="A",b="BB"}).
35
35
36 expand_recs(M,List) when is_list(List) ->
36 expand_recs(M,List) when is_list(List) ->
37 [expand_recs(M,L)||L<-List];
37 [expand_recs(M,L)||L<-List];
38 expand_recs(M,Tup) when is_tuple(Tup) ->
38 expand_recs(M,Tup) when is_tuple(Tup) ->
39 case tuple_size(Tup) of
39 case tuple_size(Tup) of
40 L when L < 1 -> Tup;
40 L when L < 1 -> Tup;
41 L ->
41 L ->
42 try Fields = M:rec_info(element(1,Tup)),
42 try Fields = M:rec_info(element(1,Tup)),
43 L = length(Fields)+1,
43 L = length(Fields)+1,
44 lists:zip(Fields,expand_recs(M,tl(tuple_to_list(Tup))))
44 lists:zip(Fields,expand_recs(M,tl(tuple_to_list(Tup))))
45 catch _:_ ->
45 catch _:_ ->
46 list_to_tuple(expand_recs(M,tuple_to_list(Tup)))
46 list_to_tuple(expand_recs(M,tuple_to_list(Tup)))
47 end
47 end
48 end;
48 end;
49 expand_recs(_,Term) ->
49 expand_recs(_,Term) ->
50 Term.
50 Term.
51 </textarea></form>
51 </textarea></form>
52
52
53 <script>
53 <script>
54 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
54 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
55 lineNumbers: true,
55 lineNumbers: true,
56 matchBrackets: true,
56 matchBrackets: true,
57 extraKeys: {"Tab": "indentAuto"},
57 extraKeys: {"Tab": "indentAuto"},
58 theme: "erlang-dark"
58 theme: "erlang-dark"
59 });
59 });
60 </script>
60 </script>
61
61
62 <p><strong>MIME types defined:</strong> <code>text/x-erlang</code>.</p>
62 <p><strong>MIME types defined:</strong> <code>text/x-erlang</code>.</p>
63 </body>
63 </body>
64 </html>
64 </html>
@@ -1,57 +1,57 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: Gas mode</title>
5 <title>CodeMirror: Gas mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="gas.js"></script>
8 <script src="gas.js"></script>
9 <link rel="stylesheet" href="../../doc/docs.css">
9 <link rel="stylesheet" href="../../doc/docs.css">
10 <style>.CodeMirror {border: 2px inset #dee;}</style>
10 <style>.CodeMirror {border: 2px inset #dee;}</style>
11 </head>
11 </head>
12 <body>
12 <body>
13 <h1>CodeMirror: Gas mode</h1>
13 <h1>CodeMirror: Gas mode</h1>
14
14
15 <form>
15 <form>
16 <textarea id="code" name="code">
16 <textarea id="code" name="code">
17 .syntax unified
17 .syntax unified
18 .global main
18 .global main
19
19
20 /*
20 /*
21 * A
21 * A
22 * multi-line
22 * multi-line
23 * comment.
23 * comment.
24 */
24 */
25
25
26 @ A single line comment.
26 @ A single line comment.
27
27
28 main:
28 main:
29 push {sp, lr}
29 push {sp, lr}
30 ldr r0, =message
30 ldr r0, =message
31 bl puts
31 bl puts
32 mov r0, #0
32 mov r0, #0
33 pop {sp, pc}
33 pop {sp, pc}
34
34
35 message:
35 message:
36 .asciz "Hello world!<br />"
36 .asciz "Hello world!<br />"
37 </textarea>
37 </textarea>
38 </form>
38 </form>
39
39
40 <script>
40 <script>
41 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
41 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
42 lineNumbers: true,
42 lineNumbers: true,
43 mode: {name: "gas", architecture: "ARMv6"},
43 mode: {name: "gas", architecture: "ARMv6"},
44 });
44 });
45 </script>
45 </script>
46
46
47 <p>Handles AT&amp;T assembler syntax (more specifically this handles
47 <p>Handles AT&amp;T assembler syntax (more specifically this handles
48 the GNU Assembler (gas) syntax.)
48 the GNU Assembler (gas) syntax.)
49 It takes a single optional configuration parameter:
49 It takes a single optional configuration parameter:
50 <code>architecture</code>, which can be one of <code>"ARM"</code>,
50 <code>architecture</code>, which can be one of <code>"ARM"</code>,
51 <code>"ARMv6"</code> or <code>"x86"</code>.
51 <code>"ARMv6"</code> or <code>"x86"</code>.
52 Including the parameter adds syntax for the registers and special
52 Including the parameter adds syntax for the registers and special
53 directives for the supplied architecture.
53 directives for the supplied architecture.
54
54
55 <p><strong>MIME types defined:</strong> <code>text/x-gas</code></p>
55 <p><strong>MIME types defined:</strong> <code>text/x-gas</code></p>
56 </body>
56 </body>
57 </html>
57 </html>
@@ -1,74 +1,74 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: GFM mode</title>
5 <title>CodeMirror: GFM mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="../../addon/mode/overlay.js"></script>
8 <script src="../../addon/mode/overlay.js"></script>
9 <script src="../xml/xml.js"></script>
9 <script src="../xml/xml.js"></script>
10 <script src="../markdown/markdown.js"></script>
10 <script src="../markdown/markdown.js"></script>
11 <script src="gfm.js"></script>
11 <script src="gfm.js"></script>
12
12
13 <!-- Code block highlighting modes -->
13 <!-- Code block highlighting modes -->
14 <script src="../javascript/javascript.js"></script>
14 <script src="../javascript/javascript.js"></script>
15 <script src="../css/css.js"></script>
15 <script src="../css/css.js"></script>
16 <script src="../htmlmixed/htmlmixed.js"></script>
16 <script src="../htmlmixed/htmlmixed.js"></script>
17 <script src="../clike/clike.js"></script>
17 <script src="../clike/clike.js"></script>
18
18
19 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
19 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
20 <link rel="stylesheet" href="../../doc/docs.css">
20 <link rel="stylesheet" href="../../doc/docs.css">
21 </head>
21 </head>
22 <body>
22 <body>
23 <h1>CodeMirror: GFM mode</h1>
23 <h1>CodeMirror: GFM mode</h1>
24
24
25 <form><textarea id="code" name="code">
25 <form><textarea id="code" name="code">
26 GitHub Flavored Markdown
26 GitHub Flavored Markdown
27 ========================
27 ========================
28
28
29 Everything from markdown plus GFM features:
29 Everything from markdown plus GFM features:
30
30
31 ## URL autolinking
31 ## URL autolinking
32
32
33 Underscores_are_allowed_between_words.
33 Underscores_are_allowed_between_words.
34
34
35 ## Fenced code blocks (and syntax highlighting)
35 ## Fenced code blocks (and syntax highlighting)
36
36
37 ```javascript
37 ```javascript
38 for (var i = 0; i &lt; items.length; i++) {
38 for (var i = 0; i &lt; items.length; i++) {
39 console.log(items[i], i); // log them
39 console.log(items[i], i); // log them
40 }
40 }
41 ```
41 ```
42
42
43 ## Task Lists
43 ## Task Lists
44
44
45 - [ ] Incomplete task list item
45 - [ ] Incomplete task list item
46 - [x] **Completed** task list item
46 - [x] **Completed** task list item
47
47
48 ## A bit of GitHub spice
48 ## A bit of GitHub spice
49
49
50 * SHA: be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
50 * SHA: be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
51 * User@SHA ref: mojombo@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
51 * User@SHA ref: mojombo@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
52 * User/Project@SHA: mojombo/god@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
52 * User/Project@SHA: mojombo/god@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
53 * \#Num: #1
53 * \#Num: #1
54 * User/#Num: mojombo#1
54 * User/#Num: mojombo#1
55 * User/Project#Num: mojombo/god#1
55 * User/Project#Num: mojombo/god#1
56
56
57 See http://github.github.com/github-flavored-markdown/.
57 See http://github.github.com/github-flavored-markdown/.
58
58
59 </textarea></form>
59 </textarea></form>
60
60
61 <script>
61 <script>
62 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
62 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
63 mode: 'gfm',
63 mode: 'gfm',
64 lineNumbers: true,
64 lineNumbers: true,
65 theme: "default"
65 theme: "default"
66 });
66 });
67 </script>
67 </script>
68
68
69 <p>Optionally depends on other modes for properly highlighted code blocks.</p>
69 <p>Optionally depends on other modes for properly highlighted code blocks.</p>
70
70
71 <p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#gfm_*">normal</a>, <a href="../../test/index.html#verbose,gfm_*">verbose</a>.</p>
71 <p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#gfm_*">normal</a>, <a href="../../test/index.html#verbose,gfm_*">verbose</a>.</p>
72
72
73 </body>
73 </body>
74 </html>
74 </html>
@@ -1,74 +1,74 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: Go mode</title>
5 <title>CodeMirror: Go mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <link rel="stylesheet" href="../../theme/elegant.css">
7 <link rel="stylesheet" href="../../theme/elegant.css">
8 <script src="../../lib/codemirror.js"></script>
8 <script src="../../lib/codemirror.js"></script>
9 <script src="../../addon/edit/matchbrackets.js"></script>
9 <script src="../../addon/edit/matchbrackets.js"></script>
10 <script src="go.js"></script>
10 <script src="go.js"></script>
11 <link rel="stylesheet" href="../../doc/docs.css">
11 <link rel="stylesheet" href="../../doc/docs.css">
12 <style>.CodeMirror {border:1px solid #999; background:#ffc}</style>
12 <style>.CodeMirror {border:1px solid #999; background:#ffc}</style>
13 </head>
13 </head>
14 <body>
14 <body>
15 <h1>CodeMirror: Go mode</h1>
15 <h1>CodeMirror: Go mode</h1>
16
16
17 <form><textarea id="code" name="code">
17 <form><textarea id="code" name="code">
18 // Prime Sieve in Go.
18 // Prime Sieve in Go.
19 // Taken from the Go specification.
19 // Taken from the Go specification.
20 // Copyright © The Go Authors.
20 // Copyright © The Go Authors.
21
21
22 package main
22 package main
23
23
24 import "fmt"
24 import "fmt"
25
25
26 // Send the sequence 2, 3, 4, ... to channel 'ch'.
26 // Send the sequence 2, 3, 4, ... to channel 'ch'.
27 func generate(ch chan&lt;- int) {
27 func generate(ch chan&lt;- int) {
28 for i := 2; ; i++ {
28 for i := 2; ; i++ {
29 ch &lt;- i // Send 'i' to channel 'ch'
29 ch &lt;- i // Send 'i' to channel 'ch'
30 }
30 }
31 }
31 }
32
32
33 // Copy the values from channel 'src' to channel 'dst',
33 // Copy the values from channel 'src' to channel 'dst',
34 // removing those divisible by 'prime'.
34 // removing those divisible by 'prime'.
35 func filter(src &lt;-chan int, dst chan&lt;- int, prime int) {
35 func filter(src &lt;-chan int, dst chan&lt;- int, prime int) {
36 for i := range src { // Loop over values received from 'src'.
36 for i := range src { // Loop over values received from 'src'.
37 if i%prime != 0 {
37 if i%prime != 0 {
38 dst &lt;- i // Send 'i' to channel 'dst'.
38 dst &lt;- i // Send 'i' to channel 'dst'.
39 }
39 }
40 }
40 }
41 }
41 }
42
42
43 // The prime sieve: Daisy-chain filter processes together.
43 // The prime sieve: Daisy-chain filter processes together.
44 func sieve() {
44 func sieve() {
45 ch := make(chan int) // Create a new channel.
45 ch := make(chan int) // Create a new channel.
46 go generate(ch) // Start generate() as a subprocess.
46 go generate(ch) // Start generate() as a subprocess.
47 for {
47 for {
48 prime := &lt;-ch
48 prime := &lt;-ch
49 fmt.Print(prime, "\n")
49 fmt.Print(prime, "\n")
50 ch1 := make(chan int)
50 ch1 := make(chan int)
51 go filter(ch, ch1, prime)
51 go filter(ch, ch1, prime)
52 ch = ch1
52 ch = ch1
53 }
53 }
54 }
54 }
55
55
56 func main() {
56 func main() {
57 sieve()
57 sieve()
58 }
58 }
59 </textarea></form>
59 </textarea></form>
60
60
61 <script>
61 <script>
62 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
62 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
63 theme: "elegant",
63 theme: "elegant",
64 matchBrackets: true,
64 matchBrackets: true,
65 indentUnit: 8,
65 indentUnit: 8,
66 tabSize: 8,
66 tabSize: 8,
67 indentWithTabs: true,
67 indentWithTabs: true,
68 mode: "text/x-go"
68 mode: "text/x-go"
69 });
69 });
70 </script>
70 </script>
71
71
72 <p><strong>MIME type:</strong> <code>text/x-go</code></p>
72 <p><strong>MIME type:</strong> <code>text/x-go</code></p>
73 </body>
73 </body>
74 </html>
74 </html>
@@ -1,62 +1,62 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: Haskell mode</title>
5 <title>CodeMirror: Haskell mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="../../addon/edit/matchbrackets.js"></script>
8 <script src="../../addon/edit/matchbrackets.js"></script>
9 <script src="haskell.js"></script>
9 <script src="haskell.js"></script>
10 <link rel="stylesheet" href="../../theme/elegant.css">
10 <link rel="stylesheet" href="../../theme/elegant.css">
11 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
11 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
12 <link rel="stylesheet" href="../../doc/docs.css">
12 <link rel="stylesheet" href="../../doc/docs.css">
13 </head>
13 </head>
14 <body>
14 <body>
15 <h1>CodeMirror: Haskell mode</h1>
15 <h1>CodeMirror: Haskell mode</h1>
16
16
17 <form><textarea id="code" name="code">
17 <form><textarea id="code" name="code">
18 module UniquePerms (
18 module UniquePerms (
19 uniquePerms
19 uniquePerms
20 )
20 )
21 where
21 where
22
22
23 -- | Find all unique permutations of a list where there might be duplicates.
23 -- | Find all unique permutations of a list where there might be duplicates.
24 uniquePerms :: (Eq a) => [a] -> [[a]]
24 uniquePerms :: (Eq a) => [a] -> [[a]]
25 uniquePerms = permBag . makeBag
25 uniquePerms = permBag . makeBag
26
26
27 -- | An unordered collection where duplicate values are allowed,
27 -- | An unordered collection where duplicate values are allowed,
28 -- but represented with a single value and a count.
28 -- but represented with a single value and a count.
29 type Bag a = [(a, Int)]
29 type Bag a = [(a, Int)]
30
30
31 makeBag :: (Eq a) => [a] -> Bag a
31 makeBag :: (Eq a) => [a] -> Bag a
32 makeBag [] = []
32 makeBag [] = []
33 makeBag (a:as) = mix a $ makeBag as
33 makeBag (a:as) = mix a $ makeBag as
34 where
34 where
35 mix a [] = [(a,1)]
35 mix a [] = [(a,1)]
36 mix a (bn@(b,n):bs) | a == b = (b,n+1):bs
36 mix a (bn@(b,n):bs) | a == b = (b,n+1):bs
37 | otherwise = bn : mix a bs
37 | otherwise = bn : mix a bs
38
38
39 permBag :: Bag a -> [[a]]
39 permBag :: Bag a -> [[a]]
40 permBag [] = [[]]
40 permBag [] = [[]]
41 permBag bs = concatMap (\(f,cs) -> map (f:) $ permBag cs) . oneOfEach $ bs
41 permBag bs = concatMap (\(f,cs) -> map (f:) $ permBag cs) . oneOfEach $ bs
42 where
42 where
43 oneOfEach [] = []
43 oneOfEach [] = []
44 oneOfEach (an@(a,n):bs) =
44 oneOfEach (an@(a,n):bs) =
45 let bs' = if n == 1 then bs else (a,n-1):bs
45 let bs' = if n == 1 then bs else (a,n-1):bs
46 in (a,bs') : mapSnd (an:) (oneOfEach bs)
46 in (a,bs') : mapSnd (an:) (oneOfEach bs)
47
47
48 apSnd f (a,b) = (a, f b)
48 apSnd f (a,b) = (a, f b)
49 mapSnd = map . apSnd
49 mapSnd = map . apSnd
50 </textarea></form>
50 </textarea></form>
51
51
52 <script>
52 <script>
53 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
53 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
54 lineNumbers: true,
54 lineNumbers: true,
55 matchBrackets: true,
55 matchBrackets: true,
56 theme: "elegant"
56 theme: "elegant"
57 });
57 });
58 </script>
58 </script>
59
59
60 <p><strong>MIME types defined:</strong> <code>text/x-haskell</code>.</p>
60 <p><strong>MIME types defined:</strong> <code>text/x-haskell</code>.</p>
61 </body>
61 </body>
62 </html>
62 </html>
@@ -1,90 +1,90 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: Haxe mode</title>
5 <title>CodeMirror: Haxe mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="haxe.js"></script>
8 <script src="haxe.js"></script>
9 <link rel="stylesheet" href="../../doc/docs.css">
9 <link rel="stylesheet" href="../../doc/docs.css">
10 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
10 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
11 </head>
11 </head>
12 <body>
12 <body>
13 <h1>CodeMirror: Haxe mode</h1>
13 <h1>CodeMirror: Haxe mode</h1>
14
14
15 <div><textarea id="code" name="code">
15 <div><textarea id="code" name="code">
16 import one.two.Three;
16 import one.two.Three;
17
17
18 @attr("test")
18 @attr("test")
19 class Foo&lt;T&gt; extends Three
19 class Foo&lt;T&gt; extends Three
20 {
20 {
21 public function new()
21 public function new()
22 {
22 {
23 noFoo = 12;
23 noFoo = 12;
24 }
24 }
25
25
26 public static inline function doFoo(obj:{k:Int, l:Float}):Int
26 public static inline function doFoo(obj:{k:Int, l:Float}):Int
27 {
27 {
28 for(i in 0...10)
28 for(i in 0...10)
29 {
29 {
30 obj.k++;
30 obj.k++;
31 trace(i);
31 trace(i);
32 var var1 = new Array();
32 var var1 = new Array();
33 if(var1.length > 1)
33 if(var1.length > 1)
34 throw "Error";
34 throw "Error";
35 }
35 }
36 // The following line should not be colored, the variable is scoped out
36 // The following line should not be colored, the variable is scoped out
37 var1;
37 var1;
38 /* Multi line
38 /* Multi line
39 * Comment test
39 * Comment test
40 */
40 */
41 return obj.k;
41 return obj.k;
42 }
42 }
43 private function bar():Void
43 private function bar():Void
44 {
44 {
45 #if flash
45 #if flash
46 var t1:String = "1.21";
46 var t1:String = "1.21";
47 #end
47 #end
48 try {
48 try {
49 doFoo({k:3, l:1.2});
49 doFoo({k:3, l:1.2});
50 }
50 }
51 catch (e : String) {
51 catch (e : String) {
52 trace(e);
52 trace(e);
53 }
53 }
54 var t2:Float = cast(3.2);
54 var t2:Float = cast(3.2);
55 var t3:haxe.Timer = new haxe.Timer();
55 var t3:haxe.Timer = new haxe.Timer();
56 var t4 = {k:Std.int(t2), l:Std.parseFloat(t1)};
56 var t4 = {k:Std.int(t2), l:Std.parseFloat(t1)};
57 var t5 = ~/123+.*$/i;
57 var t5 = ~/123+.*$/i;
58 doFoo(t4);
58 doFoo(t4);
59 untyped t1 = 4;
59 untyped t1 = 4;
60 bob = new Foo&lt;Int&gt;
60 bob = new Foo&lt;Int&gt;
61 }
61 }
62 public var okFoo(default, never):Float;
62 public var okFoo(default, never):Float;
63 var noFoo(getFoo, null):Int;
63 var noFoo(getFoo, null):Int;
64 function getFoo():Int {
64 function getFoo():Int {
65 return noFoo;
65 return noFoo;
66 }
66 }
67
67
68 public var three:Int;
68 public var three:Int;
69 }
69 }
70 enum Color
70 enum Color
71 {
71 {
72 red;
72 red;
73 green;
73 green;
74 blue;
74 blue;
75 grey( v : Int );
75 grey( v : Int );
76 rgb (r:Int,g:Int,b:Int);
76 rgb (r:Int,g:Int,b:Int);
77 }
77 }
78 </textarea></div>
78 </textarea></div>
79
79
80 <script>
80 <script>
81 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
81 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
82 lineNumbers: true,
82 lineNumbers: true,
83 indentUnit: 4,
83 indentUnit: 4,
84 indentWithTabs: true
84 indentWithTabs: true
85 });
85 });
86 </script>
86 </script>
87
87
88 <p><strong>MIME types defined:</strong> <code>text/x-haxe</code>.</p>
88 <p><strong>MIME types defined:</strong> <code>text/x-haxe</code>.</p>
89 </body>
89 </body>
90 </html>
90 </html>
@@ -1,49 +1,49 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: Html Embedded Scripts mode</title>
5 <title>CodeMirror: Html Embedded Scripts mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="../xml/xml.js"></script>
8 <script src="../xml/xml.js"></script>
9 <script src="../javascript/javascript.js"></script>
9 <script src="../javascript/javascript.js"></script>
10 <script src="../css/css.js"></script>
10 <script src="../css/css.js"></script>
11 <script src="../htmlmixed/htmlmixed.js"></script>
11 <script src="../htmlmixed/htmlmixed.js"></script>
12 <script src="htmlembedded.js"></script>
12 <script src="htmlembedded.js"></script>
13 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
13 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
14 <link rel="stylesheet" href="../../doc/docs.css">
14 <link rel="stylesheet" href="../../doc/docs.css">
15 </head>
15 </head>
16 <body>
16 <body>
17 <h1>CodeMirror: Html Embedded Scripts mode</h1>
17 <h1>CodeMirror: Html Embedded Scripts mode</h1>
18
18
19 <form><textarea id="code" name="code">
19 <form><textarea id="code" name="code">
20 <%
20 <%
21 function hello(who) {
21 function hello(who) {
22 return "Hello " + who;
22 return "Hello " + who;
23 }
23 }
24 %>
24 %>
25 This is an example of EJS (embedded javascript)
25 This is an example of EJS (embedded javascript)
26 <p>The program says <%= hello("world") %>.</p>
26 <p>The program says <%= hello("world") %>.</p>
27 <script>
27 <script>
28 alert("And here is some normal JS code"); // also colored
28 alert("And here is some normal JS code"); // also colored
29 </script>
29 </script>
30 </textarea></form>
30 </textarea></form>
31
31
32 <script>
32 <script>
33 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
33 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
34 lineNumbers: true,
34 lineNumbers: true,
35 mode: "application/x-ejs",
35 mode: "application/x-ejs",
36 indentUnit: 4,
36 indentUnit: 4,
37 indentWithTabs: true,
37 indentWithTabs: true,
38 enterMode: "keep",
38 enterMode: "keep",
39 tabMode: "shift"
39 tabMode: "shift"
40 });
40 });
41 </script>
41 </script>
42
42
43 <p>Mode for html embedded scripts like JSP and ASP.NET. Depends on HtmlMixed which in turn depends on
43 <p>Mode for html embedded scripts like JSP and ASP.NET. Depends on HtmlMixed which in turn depends on
44 JavaScript, CSS and XML.<br />Other dependancies include those of the scriping language chosen.</p>
44 JavaScript, CSS and XML.<br />Other dependancies include those of the scriping language chosen.</p>
45
45
46 <p><strong>MIME types defined:</strong> <code>application/x-aspx</code> (ASP.NET),
46 <p><strong>MIME types defined:</strong> <code>application/x-aspx</code> (ASP.NET),
47 <code>application/x-ejs</code> (Embedded Javascript), <code>application/x-jsp</code> (JavaServer Pages)</p>
47 <code>application/x-ejs</code> (Embedded Javascript), <code>application/x-jsp</code> (JavaServer Pages)</p>
48 </body>
48 </body>
49 </html>
49 </html>
@@ -1,32 +1,32 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: HTTP mode</title>
5 <title>CodeMirror: HTTP mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="http.js"></script>
8 <script src="http.js"></script>
9 <link rel="stylesheet" href="../../doc/docs.css">
9 <link rel="stylesheet" href="../../doc/docs.css">
10 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
10 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
11 </head>
11 </head>
12 <body>
12 <body>
13 <h1>CodeMirror: HTTP mode</h1>
13 <h1>CodeMirror: HTTP mode</h1>
14
14
15 <div><textarea id="code" name="code">
15 <div><textarea id="code" name="code">
16 POST /somewhere HTTP/1.1
16 POST /somewhere HTTP/1.1
17 Host: example.com
17 Host: example.com
18 If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT
18 If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT
19 Content-Type: application/x-www-form-urlencoded;
19 Content-Type: application/x-www-form-urlencoded;
20 charset=utf-8
20 charset=utf-8
21 User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.11 (KHTML, like Gecko) Ubuntu/12.04 Chromium/20.0.1132.47 Chrome/20.0.1132.47 Safari/536.11
21 User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.11 (KHTML, like Gecko) Ubuntu/12.04 Chromium/20.0.1132.47 Chrome/20.0.1132.47 Safari/536.11
22
22
23 This is the request body!
23 This is the request body!
24 </textarea></div>
24 </textarea></div>
25
25
26 <script>
26 <script>
27 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
27 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
28 </script>
28 </script>
29
29
30 <p><strong>MIME types defined:</strong> <code>message/http</code>.</p>
30 <p><strong>MIME types defined:</strong> <code>message/http</code>.</p>
31 </body>
31 </body>
32 </html>
32 </html>
@@ -1,48 +1,48 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: TypeScript mode</title>
5 <title>CodeMirror: TypeScript mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="javascript.js"></script>
8 <script src="javascript.js"></script>
9 <link rel="stylesheet" href="../../doc/docs.css">
9 <link rel="stylesheet" href="../../doc/docs.css">
10 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
10 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
11 </head>
11 </head>
12 <body>
12 <body>
13 <h1>CodeMirror: TypeScript mode</h1>
13 <h1>CodeMirror: TypeScript mode</h1>
14
14
15 <div><textarea id="code" name="code">
15 <div><textarea id="code" name="code">
16 class Greeter {
16 class Greeter {
17 greeting: string;
17 greeting: string;
18 constructor (message: string) {
18 constructor (message: string) {
19 this.greeting = message;
19 this.greeting = message;
20 }
20 }
21 greet() {
21 greet() {
22 return "Hello, " + this.greeting;
22 return "Hello, " + this.greeting;
23 }
23 }
24 }
24 }
25
25
26 var greeter = new Greeter("world");
26 var greeter = new Greeter("world");
27
27
28 var button = document.createElement('button')
28 var button = document.createElement('button')
29 button.innerText = "Say Hello"
29 button.innerText = "Say Hello"
30 button.onclick = function() {
30 button.onclick = function() {
31 alert(greeter.greet())
31 alert(greeter.greet())
32 }
32 }
33
33
34 document.body.appendChild(button)
34 document.body.appendChild(button)
35
35
36 </textarea></div>
36 </textarea></div>
37
37
38 <script>
38 <script>
39 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
39 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
40 lineNumbers: true,
40 lineNumbers: true,
41 matchBrackets: true,
41 matchBrackets: true,
42 mode: "text/typescript"
42 mode: "text/typescript"
43 });
43 });
44 </script>
44 </script>
45
45
46 <p>This is a specialization of the <a href="index.html">JavaScript mode</a>.</p>
46 <p>This is a specialization of the <a href="index.html">JavaScript mode</a>.</p>
47 </body>
47 </body>
48 </html>
48 </html>
@@ -1,741 +1,741 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: LESS mode</title>
5 <title>CodeMirror: LESS mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="../../addon/edit/matchbrackets.js"></script>
8 <script src="../../addon/edit/matchbrackets.js"></script>
9 <script src="less.js"></script>
9 <script src="less.js"></script>
10 <style>.CodeMirror {background: #f8f8f8; border: 1px solid #ddd; font-size:12px; height: 400px}</style>
10 <style>.CodeMirror {background: #f8f8f8; border: 1px solid #ddd; font-size:12px; height: 400px}</style>
11 <link rel="stylesheet" href="../../doc/docs.css">
11 <link rel="stylesheet" href="../../doc/docs.css">
12 <link rel="stylesheet" href="../../theme/lesser-dark.css">
12 <link rel="stylesheet" href="../../theme/lesser-dark.css">
13 </head>
13 </head>
14 <body>
14 <body>
15 <h1>CodeMirror: LESS mode</h1>
15 <h1>CodeMirror: LESS mode</h1>
16 <form><textarea id="code" name="code">@media screen and (device-aspect-ratio: 16/9) { … }
16 <form><textarea id="code" name="code">@media screen and (device-aspect-ratio: 16/9) { … }
17 @media screen and (device-aspect-ratio: 32/18) { … }
17 @media screen and (device-aspect-ratio: 32/18) { … }
18 @media screen and (device-aspect-ratio: 1280/720) { … }
18 @media screen and (device-aspect-ratio: 1280/720) { … }
19 @media screen and (device-aspect-ratio: 2560/1440) { … }
19 @media screen and (device-aspect-ratio: 2560/1440) { … }
20
20
21 html:lang(fr-be)
21 html:lang(fr-be)
22 html:lang(de)
22 html:lang(de)
23 :lang(fr-be) > q
23 :lang(fr-be) > q
24 :lang(de) > q
24 :lang(de) > q
25
25
26 tr:nth-child(2n+1) /* represents every odd row of an HTML table */
26 tr:nth-child(2n+1) /* represents every odd row of an HTML table */
27 tr:nth-child(odd) /* same */
27 tr:nth-child(odd) /* same */
28 tr:nth-child(2n+0) /* represents every even row of an HTML table */
28 tr:nth-child(2n+0) /* represents every even row of an HTML table */
29 tr:nth-child(even) /* same */
29 tr:nth-child(even) /* same */
30
30
31 /* Alternate paragraph colours in CSS */
31 /* Alternate paragraph colours in CSS */
32 p:nth-child(4n+1) { color: navy; }
32 p:nth-child(4n+1) { color: navy; }
33 p:nth-child(4n+2) { color: green; }
33 p:nth-child(4n+2) { color: green; }
34 p:nth-child(4n+3) { color: maroon; }
34 p:nth-child(4n+3) { color: maroon; }
35 p:nth-child(4n+4) { color: purple; }
35 p:nth-child(4n+4) { color: purple; }
36
36
37 :nth-child(10n-1) /* represents the 9th, 19th, 29th, etc, element */
37 :nth-child(10n-1) /* represents the 9th, 19th, 29th, etc, element */
38 :nth-child(10n+9) /* Same */
38 :nth-child(10n+9) /* Same */
39 :nth-child(10n+-1) /* Syntactically invalid, and would be ignored */
39 :nth-child(10n+-1) /* Syntactically invalid, and would be ignored */
40
40
41 :nth-child( 3n + 1 )
41 :nth-child( 3n + 1 )
42 :nth-child( +3n - 2 )
42 :nth-child( +3n - 2 )
43 :nth-child( -n+ 6)
43 :nth-child( -n+ 6)
44 :nth-child( +6 )
44 :nth-child( +6 )
45
45
46 html|tr:nth-child(-n+6) /* represents the 6 first rows of XHTML tables */
46 html|tr:nth-child(-n+6) /* represents the 6 first rows of XHTML tables */
47
47
48 img:nth-of-type(2n+1) { float: right; }
48 img:nth-of-type(2n+1) { float: right; }
49 img:nth-of-type(2n) { float: left; }
49 img:nth-of-type(2n) { float: left; }
50
50
51 body > h2:nth-of-type(n+2):nth-last-of-type(n+2)
51 body > h2:nth-of-type(n+2):nth-last-of-type(n+2)
52 body > h2:not(:first-of-type):not(:last-of-type)
52 body > h2:not(:first-of-type):not(:last-of-type)
53
53
54 html|*:not(:link):not(:visited)
54 html|*:not(:link):not(:visited)
55 *|*:not(:hover)
55 *|*:not(:hover)
56 p::first-line { text-transform: uppercase }
56 p::first-line { text-transform: uppercase }
57
57
58 p { color: red; font-size: 12pt }
58 p { color: red; font-size: 12pt }
59 p::first-letter { color: green; font-size: 200% }
59 p::first-letter { color: green; font-size: 200% }
60 p::first-line { color: blue }
60 p::first-line { color: blue }
61
61
62 p { line-height: 1.1 }
62 p { line-height: 1.1 }
63 p::first-letter { font-size: 3em; font-weight: normal }
63 p::first-letter { font-size: 3em; font-weight: normal }
64 span { font-weight: bold }
64 span { font-weight: bold }
65
65
66 * /* a=0 b=0 c=0 -> specificity = 0 */
66 * /* a=0 b=0 c=0 -> specificity = 0 */
67 LI /* a=0 b=0 c=1 -> specificity = 1 */
67 LI /* a=0 b=0 c=1 -> specificity = 1 */
68 UL LI /* a=0 b=0 c=2 -> specificity = 2 */
68 UL LI /* a=0 b=0 c=2 -> specificity = 2 */
69 UL OL+LI /* a=0 b=0 c=3 -> specificity = 3 */
69 UL OL+LI /* a=0 b=0 c=3 -> specificity = 3 */
70 H1 + *[REL=up] /* a=0 b=1 c=1 -> specificity = 11 */
70 H1 + *[REL=up] /* a=0 b=1 c=1 -> specificity = 11 */
71 UL OL LI.red /* a=0 b=1 c=3 -> specificity = 13 */
71 UL OL LI.red /* a=0 b=1 c=3 -> specificity = 13 */
72 LI.red.level /* a=0 b=2 c=1 -> specificity = 21 */
72 LI.red.level /* a=0 b=2 c=1 -> specificity = 21 */
73 #x34y /* a=1 b=0 c=0 -> specificity = 100 */
73 #x34y /* a=1 b=0 c=0 -> specificity = 100 */
74 #s12:not(FOO) /* a=1 b=0 c=1 -> specificity = 101 */
74 #s12:not(FOO) /* a=1 b=0 c=1 -> specificity = 101 */
75
75
76 @namespace foo url(http://www.example.com);
76 @namespace foo url(http://www.example.com);
77 foo|h1 { color: blue } /* first rule */
77 foo|h1 { color: blue } /* first rule */
78 foo|* { color: yellow } /* second rule */
78 foo|* { color: yellow } /* second rule */
79 |h1 { color: red } /* ...*/
79 |h1 { color: red } /* ...*/
80 *|h1 { color: green }
80 *|h1 { color: green }
81 h1 { color: green }
81 h1 { color: green }
82
82
83 span[hello="Ocean"][goodbye="Land"]
83 span[hello="Ocean"][goodbye="Land"]
84
84
85 a[rel~="copyright"] { ... }
85 a[rel~="copyright"] { ... }
86 a[href="http://www.w3.org/"] { ... }
86 a[href="http://www.w3.org/"] { ... }
87
87
88 DIALOGUE[character=romeo]
88 DIALOGUE[character=romeo]
89 DIALOGUE[character=juliet]
89 DIALOGUE[character=juliet]
90
90
91 [att^=val]
91 [att^=val]
92 [att$=val]
92 [att$=val]
93 [att*=val]
93 [att*=val]
94
94
95 @namespace foo "http://www.example.com";
95 @namespace foo "http://www.example.com";
96 [foo|att=val] { color: blue }
96 [foo|att=val] { color: blue }
97 [*|att] { color: yellow }
97 [*|att] { color: yellow }
98 [|att] { color: green }
98 [|att] { color: green }
99 [att] { color: green }
99 [att] { color: green }
100
100
101
101
102 *:target { color : red }
102 *:target { color : red }
103 *:target::before { content : url(target.png) }
103 *:target::before { content : url(target.png) }
104
104
105 E[foo]{
105 E[foo]{
106 padding:65px;
106 padding:65px;
107 }
107 }
108 E[foo] ~ F{
108 E[foo] ~ F{
109 padding:65px;
109 padding:65px;
110 }
110 }
111 E#myid{
111 E#myid{
112 padding:65px;
112 padding:65px;
113 }
113 }
114 input[type="search"]::-webkit-search-decoration,
114 input[type="search"]::-webkit-search-decoration,
115 input[type="search"]::-webkit-search-cancel-button {
115 input[type="search"]::-webkit-search-cancel-button {
116 -webkit-appearance: none; // Inner-padding issues in Chrome OSX, Safari 5
116 -webkit-appearance: none; // Inner-padding issues in Chrome OSX, Safari 5
117 }
117 }
118 button::-moz-focus-inner,
118 button::-moz-focus-inner,
119 input::-moz-focus-inner { // Inner padding and border oddities in FF3/4
119 input::-moz-focus-inner { // Inner padding and border oddities in FF3/4
120 padding: 0;
120 padding: 0;
121 border: 0;
121 border: 0;
122 }
122 }
123 .btn {
123 .btn {
124 // reset here as of 2.0.3 due to Recess property order
124 // reset here as of 2.0.3 due to Recess property order
125 border-color: #ccc;
125 border-color: #ccc;
126 border-color: rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);
126 border-color: rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);
127 }
127 }
128 fieldset span button, fieldset span input[type="file"] {
128 fieldset span button, fieldset span input[type="file"] {
129 font-size:12px;
129 font-size:12px;
130 font-family:Arial, Helvetica, sans-serif;
130 font-family:Arial, Helvetica, sans-serif;
131 }
131 }
132 .el tr:nth-child(even):last-child td:first-child{
132 .el tr:nth-child(even):last-child td:first-child{
133 -moz-border-radius-bottomleft:3px;
133 -moz-border-radius-bottomleft:3px;
134 -webkit-border-bottom-left-radius:3px;
134 -webkit-border-bottom-left-radius:3px;
135 border-bottom-left-radius:3px;
135 border-bottom-left-radius:3px;
136 }
136 }
137
137
138 /* Some LESS code */
138 /* Some LESS code */
139
139
140 button {
140 button {
141 width: 32px;
141 width: 32px;
142 height: 32px;
142 height: 32px;
143 border: 0;
143 border: 0;
144 margin: 4px;
144 margin: 4px;
145 cursor: pointer;
145 cursor: pointer;
146 }
146 }
147 button.icon-plus { background: url(http://dahlström.net/tmp/sharp-icons/svg-icon-target.svg#plus) no-repeat; }
147 button.icon-plus { background: url(http://dahlström.net/tmp/sharp-icons/svg-icon-target.svg#plus) no-repeat; }
148 button.icon-chart { background: url(http://dahlström.net/tmp/sharp-icons/svg-icon-target.svg#chart) no-repeat; }
148 button.icon-chart { background: url(http://dahlström.net/tmp/sharp-icons/svg-icon-target.svg#chart) no-repeat; }
149
149
150 button:hover { background-color: #999; }
150 button:hover { background-color: #999; }
151 button:active { background-color: #666; }
151 button:active { background-color: #666; }
152
152
153 @test_a: #eeeQQQ;//this is not a valid hex value and thus parsed as an element id
153 @test_a: #eeeQQQ;//this is not a valid hex value and thus parsed as an element id
154 @test_b: #eeeFFF //this is a valid hex value but the declaration doesn't end with a semicolon and thus parsed as an element id
154 @test_b: #eeeFFF //this is a valid hex value but the declaration doesn't end with a semicolon and thus parsed as an element id
155
155
156 #eee aaa .box
156 #eee aaa .box
157 {
157 {
158 #test bbb {
158 #test bbb {
159 width: 500px;
159 width: 500px;
160 height: 250px;
160 height: 250px;
161 background-image: url(dir/output/sheep.png), url( betweengrassandsky.png );
161 background-image: url(dir/output/sheep.png), url( betweengrassandsky.png );
162 background-position: center bottom, left top;
162 background-position: center bottom, left top;
163 background-repeat: no-repeat;
163 background-repeat: no-repeat;
164 }
164 }
165 }
165 }
166
166
167 @base: #f938ab;
167 @base: #f938ab;
168
168
169 .box-shadow(@style, @c) when (iscolor(@c)) {
169 .box-shadow(@style, @c) when (iscolor(@c)) {
170 box-shadow: @style @c;
170 box-shadow: @style @c;
171 -webkit-box-shadow: @style @c;
171 -webkit-box-shadow: @style @c;
172 -moz-box-shadow: @style @c;
172 -moz-box-shadow: @style @c;
173 }
173 }
174 .box-shadow(@style, @alpha: 50%) when (isnumber(@alpha)) {
174 .box-shadow(@style, @alpha: 50%) when (isnumber(@alpha)) {
175 .box-shadow(@style, rgba(0, 0, 0, @alpha));
175 .box-shadow(@style, rgba(0, 0, 0, @alpha));
176 }
176 }
177
177
178 @color: #4D926F;
178 @color: #4D926F;
179
179
180 #header {
180 #header {
181 color: @color;
181 color: @color;
182 color: #000000;
182 color: #000000;
183 }
183 }
184 h2 {
184 h2 {
185 color: @color;
185 color: @color;
186 }
186 }
187
187
188 .rounded-corners (@radius: 5px) {
188 .rounded-corners (@radius: 5px) {
189 border-radius: @radius;
189 border-radius: @radius;
190 -webkit-border-radius: @radius;
190 -webkit-border-radius: @radius;
191 -moz-border-radius: @radius;
191 -moz-border-radius: @radius;
192 }
192 }
193
193
194 #header {
194 #header {
195 .rounded-corners;
195 .rounded-corners;
196 }
196 }
197 #footer {
197 #footer {
198 .rounded-corners(10px);
198 .rounded-corners(10px);
199 }
199 }
200
200
201 .box-shadow (@x: 0, @y: 0, @blur: 1px, @alpha) {
201 .box-shadow (@x: 0, @y: 0, @blur: 1px, @alpha) {
202 @val: @x @y @blur rgba(0, 0, 0, @alpha);
202 @val: @x @y @blur rgba(0, 0, 0, @alpha);
203
203
204 box-shadow: @val;
204 box-shadow: @val;
205 -webkit-box-shadow: @val;
205 -webkit-box-shadow: @val;
206 -moz-box-shadow: @val;
206 -moz-box-shadow: @val;
207 }
207 }
208 .box { @base: #f938ab;
208 .box { @base: #f938ab;
209 color: saturate(@base, 5%);
209 color: saturate(@base, 5%);
210 border-color: lighten(@base, 30%);
210 border-color: lighten(@base, 30%);
211 div { .box-shadow(0, 0, 5px, 0.4) }
211 div { .box-shadow(0, 0, 5px, 0.4) }
212 }
212 }
213
213
214 @import url("something.css");
214 @import url("something.css");
215
215
216 @light-blue: hsl(190, 50%, 65%);
216 @light-blue: hsl(190, 50%, 65%);
217 @light-yellow: desaturate(#fefec8, 10%);
217 @light-yellow: desaturate(#fefec8, 10%);
218 @dark-yellow: desaturate(darken(@light-yellow, 10%), 40%);
218 @dark-yellow: desaturate(darken(@light-yellow, 10%), 40%);
219 @darkest: hsl(20, 0%, 15%);
219 @darkest: hsl(20, 0%, 15%);
220 @dark: hsl(190, 20%, 30%);
220 @dark: hsl(190, 20%, 30%);
221 @medium: hsl(10, 60%, 30%);
221 @medium: hsl(10, 60%, 30%);
222 @light: hsl(90, 40%, 20%);
222 @light: hsl(90, 40%, 20%);
223 @lightest: hsl(90, 20%, 90%);
223 @lightest: hsl(90, 20%, 90%);
224 @highlight: hsl(80, 50%, 90%);
224 @highlight: hsl(80, 50%, 90%);
225 @blue: hsl(210, 60%, 20%);
225 @blue: hsl(210, 60%, 20%);
226 @alpha-blue: hsla(210, 60%, 40%, 0.5);
226 @alpha-blue: hsla(210, 60%, 40%, 0.5);
227
227
228 .box-shadow (@x, @y, @blur, @alpha) {
228 .box-shadow (@x, @y, @blur, @alpha) {
229 @value: @x @y @blur rgba(0, 0, 0, @alpha);
229 @value: @x @y @blur rgba(0, 0, 0, @alpha);
230 box-shadow: @value;
230 box-shadow: @value;
231 -moz-box-shadow: @value;
231 -moz-box-shadow: @value;
232 -webkit-box-shadow: @value;
232 -webkit-box-shadow: @value;
233 }
233 }
234 .border-radius (@radius) {
234 .border-radius (@radius) {
235 border-radius: @radius;
235 border-radius: @radius;
236 -moz-border-radius: @radius;
236 -moz-border-radius: @radius;
237 -webkit-border-radius: @radius;
237 -webkit-border-radius: @radius;
238 }
238 }
239
239
240 .border-radius (@radius, bottom) {
240 .border-radius (@radius, bottom) {
241 border-top-right-radius: 0;
241 border-top-right-radius: 0;
242 border-top-left-radius: 0;
242 border-top-left-radius: 0;
243 -moz-border-top-right-radius: 0;
243 -moz-border-top-right-radius: 0;
244 -moz-border-top-left-radius: 0;
244 -moz-border-top-left-radius: 0;
245 -webkit-border-top-left-radius: 0;
245 -webkit-border-top-left-radius: 0;
246 -webkit-border-top-right-radius: 0;
246 -webkit-border-top-right-radius: 0;
247 }
247 }
248 .border-radius (@radius, right) {
248 .border-radius (@radius, right) {
249 border-bottom-left-radius: 0;
249 border-bottom-left-radius: 0;
250 border-top-left-radius: 0;
250 border-top-left-radius: 0;
251 -moz-border-bottom-left-radius: 0;
251 -moz-border-bottom-left-radius: 0;
252 -moz-border-top-left-radius: 0;
252 -moz-border-top-left-radius: 0;
253 -webkit-border-bottom-left-radius: 0;
253 -webkit-border-bottom-left-radius: 0;
254 -webkit-border-top-left-radius: 0;
254 -webkit-border-top-left-radius: 0;
255 }
255 }
256 .box-shadow-inset (@x, @y, @blur, @color) {
256 .box-shadow-inset (@x, @y, @blur, @color) {
257 box-shadow: @x @y @blur @color inset;
257 box-shadow: @x @y @blur @color inset;
258 -moz-box-shadow: @x @y @blur @color inset;
258 -moz-box-shadow: @x @y @blur @color inset;
259 -webkit-box-shadow: @x @y @blur @color inset;
259 -webkit-box-shadow: @x @y @blur @color inset;
260 }
260 }
261 .code () {
261 .code () {
262 font-family: 'Bitstream Vera Sans Mono',
262 font-family: 'Bitstream Vera Sans Mono',
263 'DejaVu Sans Mono',
263 'DejaVu Sans Mono',
264 'Monaco',
264 'Monaco',
265 Courier,
265 Courier,
266 monospace !important;
266 monospace !important;
267 }
267 }
268 .wrap () {
268 .wrap () {
269 text-wrap: wrap;
269 text-wrap: wrap;
270 white-space: pre-wrap; /* css-3 */
270 white-space: pre-wrap; /* css-3 */
271 white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
271 white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
272 white-space: -pre-wrap; /* Opera 4-6 */
272 white-space: -pre-wrap; /* Opera 4-6 */
273 white-space: -o-pre-wrap; /* Opera 7 */
273 white-space: -o-pre-wrap; /* Opera 7 */
274 word-wrap: break-word; /* Internet Explorer 5.5+ */
274 word-wrap: break-word; /* Internet Explorer 5.5+ */
275 }
275 }
276
276
277 html { margin: 0 }
277 html { margin: 0 }
278 body {
278 body {
279 background-color: @darkest;
279 background-color: @darkest;
280 margin: 0 auto;
280 margin: 0 auto;
281 font-family: Arial, sans-serif;
281 font-family: Arial, sans-serif;
282 font-size: 100%;
282 font-size: 100%;
283 overflow-x: hidden;
283 overflow-x: hidden;
284 }
284 }
285 nav, header, footer, section, article {
285 nav, header, footer, section, article {
286 display: block;
286 display: block;
287 }
287 }
288 a {
288 a {
289 color: #b83000;
289 color: #b83000;
290 }
290 }
291 h1 a {
291 h1 a {
292 color: black;
292 color: black;
293 text-decoration: none;
293 text-decoration: none;
294 }
294 }
295 a:hover {
295 a:hover {
296 text-decoration: underline;
296 text-decoration: underline;
297 }
297 }
298 h1, h2, h3, h4 {
298 h1, h2, h3, h4 {
299 margin: 0;
299 margin: 0;
300 font-weight: normal;
300 font-weight: normal;
301 }
301 }
302 ul, li {
302 ul, li {
303 list-style-type: none;
303 list-style-type: none;
304 }
304 }
305 code { .code; }
305 code { .code; }
306 code {
306 code {
307 .string, .regexp { color: @dark }
307 .string, .regexp { color: @dark }
308 .keyword { font-weight: bold }
308 .keyword { font-weight: bold }
309 .comment { color: rgba(0, 0, 0, 0.5) }
309 .comment { color: rgba(0, 0, 0, 0.5) }
310 .number { color: @blue }
310 .number { color: @blue }
311 .class, .special { color: rgba(0, 50, 100, 0.8) }
311 .class, .special { color: rgba(0, 50, 100, 0.8) }
312 }
312 }
313 pre {
313 pre {
314 padding: 0 30px;
314 padding: 0 30px;
315 .wrap;
315 .wrap;
316 }
316 }
317 blockquote {
317 blockquote {
318 font-style: italic;
318 font-style: italic;
319 }
319 }
320 body > footer {
320 body > footer {
321 text-align: left;
321 text-align: left;
322 margin-left: 10px;
322 margin-left: 10px;
323 font-style: italic;
323 font-style: italic;
324 font-size: 18px;
324 font-size: 18px;
325 color: #888;
325 color: #888;
326 }
326 }
327
327
328 #logo {
328 #logo {
329 margin-top: 30px;
329 margin-top: 30px;
330 margin-bottom: 30px;
330 margin-bottom: 30px;
331 display: block;
331 display: block;
332 width: 199px;
332 width: 199px;
333 height: 81px;
333 height: 81px;
334 background: url(/images/logo.png) no-repeat;
334 background: url(/images/logo.png) no-repeat;
335 }
335 }
336 nav {
336 nav {
337 margin-left: 15px;
337 margin-left: 15px;
338 }
338 }
339 nav a, #dropdown li {
339 nav a, #dropdown li {
340 display: inline-block;
340 display: inline-block;
341 color: white;
341 color: white;
342 line-height: 42px;
342 line-height: 42px;
343 margin: 0;
343 margin: 0;
344 padding: 0px 15px;
344 padding: 0px 15px;
345 text-shadow: -1px -1px 1px rgba(0, 0, 0, 0.5);
345 text-shadow: -1px -1px 1px rgba(0, 0, 0, 0.5);
346 text-decoration: none;
346 text-decoration: none;
347 border: 2px solid transparent;
347 border: 2px solid transparent;
348 border-width: 0 2px;
348 border-width: 0 2px;
349 &:hover {
349 &:hover {
350 .dark-red;
350 .dark-red;
351 text-decoration: none;
351 text-decoration: none;
352 }
352 }
353 }
353 }
354 .dark-red {
354 .dark-red {
355 @red: @medium;
355 @red: @medium;
356 border: 2px solid darken(@red, 25%);
356 border: 2px solid darken(@red, 25%);
357 border-left-color: darken(@red, 15%);
357 border-left-color: darken(@red, 15%);
358 border-right-color: darken(@red, 15%);
358 border-right-color: darken(@red, 15%);
359 border-bottom: 0;
359 border-bottom: 0;
360 border-top: 0;
360 border-top: 0;
361 background-color: darken(@red, 10%);
361 background-color: darken(@red, 10%);
362 }
362 }
363
363
364 .content {
364 .content {
365 margin: 0 auto;
365 margin: 0 auto;
366 width: 980px;
366 width: 980px;
367 }
367 }
368
368
369 #menu {
369 #menu {
370 position: absolute;
370 position: absolute;
371 width: 100%;
371 width: 100%;
372 z-index: 3;
372 z-index: 3;
373 clear: both;
373 clear: both;
374 display: block;
374 display: block;
375 background-color: @blue;
375 background-color: @blue;
376 height: 42px;
376 height: 42px;
377 border-top: 2px solid lighten(@alpha-blue, 20%);
377 border-top: 2px solid lighten(@alpha-blue, 20%);
378 border-bottom: 2px solid darken(@alpha-blue, 25%);
378 border-bottom: 2px solid darken(@alpha-blue, 25%);
379 .box-shadow(0, 1px, 8px, 0.6);
379 .box-shadow(0, 1px, 8px, 0.6);
380 -moz-box-shadow: 0 0 0 #000; // Because firefox sucks.
380 -moz-box-shadow: 0 0 0 #000; // Because firefox sucks.
381
381
382 &.docked {
382 &.docked {
383 background-color: hsla(210, 60%, 40%, 0.4);
383 background-color: hsla(210, 60%, 40%, 0.4);
384 }
384 }
385 &:hover {
385 &:hover {
386 background-color: @blue;
386 background-color: @blue;
387 }
387 }
388
388
389 #dropdown {
389 #dropdown {
390 margin: 0 0 0 117px;
390 margin: 0 0 0 117px;
391 padding: 0;
391 padding: 0;
392 padding-top: 5px;
392 padding-top: 5px;
393 display: none;
393 display: none;
394 width: 190px;
394 width: 190px;
395 border-top: 2px solid @medium;
395 border-top: 2px solid @medium;
396 color: @highlight;
396 color: @highlight;
397 border: 2px solid darken(@medium, 25%);
397 border: 2px solid darken(@medium, 25%);
398 border-left-color: darken(@medium, 15%);
398 border-left-color: darken(@medium, 15%);
399 border-right-color: darken(@medium, 15%);
399 border-right-color: darken(@medium, 15%);
400 border-top-width: 0;
400 border-top-width: 0;
401 background-color: darken(@medium, 10%);
401 background-color: darken(@medium, 10%);
402 ul {
402 ul {
403 padding: 0px;
403 padding: 0px;
404 }
404 }
405 li {
405 li {
406 font-size: 14px;
406 font-size: 14px;
407 display: block;
407 display: block;
408 text-align: left;
408 text-align: left;
409 padding: 0;
409 padding: 0;
410 border: 0;
410 border: 0;
411 a {
411 a {
412 display: block;
412 display: block;
413 padding: 0px 15px;
413 padding: 0px 15px;
414 text-decoration: none;
414 text-decoration: none;
415 color: white;
415 color: white;
416 &:hover {
416 &:hover {
417 background-color: darken(@medium, 15%);
417 background-color: darken(@medium, 15%);
418 text-decoration: none;
418 text-decoration: none;
419 }
419 }
420 }
420 }
421 }
421 }
422 .border-radius(5px, bottom);
422 .border-radius(5px, bottom);
423 .box-shadow(0, 6px, 8px, 0.5);
423 .box-shadow(0, 6px, 8px, 0.5);
424 }
424 }
425 }
425 }
426
426
427 #main {
427 #main {
428 margin: 0 auto;
428 margin: 0 auto;
429 width: 100%;
429 width: 100%;
430 background-color: @light-blue;
430 background-color: @light-blue;
431 border-top: 8px solid darken(@light-blue, 5%);
431 border-top: 8px solid darken(@light-blue, 5%);
432
432
433 #intro {
433 #intro {
434 background-color: lighten(@light-blue, 25%);
434 background-color: lighten(@light-blue, 25%);
435 float: left;
435 float: left;
436 margin-top: -8px;
436 margin-top: -8px;
437 margin-right: 5px;
437 margin-right: 5px;
438
438
439 height: 380px;
439 height: 380px;
440 position: relative;
440 position: relative;
441 z-index: 2;
441 z-index: 2;
442 font-family: 'Droid Serif', 'Georgia';
442 font-family: 'Droid Serif', 'Georgia';
443 width: 395px;
443 width: 395px;
444 padding: 45px 20px 23px 30px;
444 padding: 45px 20px 23px 30px;
445 border: 2px dashed darken(@light-blue, 10%);
445 border: 2px dashed darken(@light-blue, 10%);
446 .box-shadow(1px, 0px, 6px, 0.5);
446 .box-shadow(1px, 0px, 6px, 0.5);
447 border-bottom: 0;
447 border-bottom: 0;
448 border-top: 0;
448 border-top: 0;
449 #download { color: transparent; border: 0; float: left; display: inline-block; margin: 15px 0 15px -5px; }
449 #download { color: transparent; border: 0; float: left; display: inline-block; margin: 15px 0 15px -5px; }
450 #download img { display: inline-block}
450 #download img { display: inline-block}
451 #download-info {
451 #download-info {
452 code {
452 code {
453 font-size: 13px;
453 font-size: 13px;
454 }
454 }
455 color: @blue + #333; display: inline; float: left; margin: 36px 0 0 15px }
455 color: @blue + #333; display: inline; float: left; margin: 36px 0 0 15px }
456 }
456 }
457 h2 {
457 h2 {
458 span {
458 span {
459 color: @medium;
459 color: @medium;
460 }
460 }
461 color: @blue;
461 color: @blue;
462 margin: 20px 0;
462 margin: 20px 0;
463 font-size: 24px;
463 font-size: 24px;
464 line-height: 1.2em;
464 line-height: 1.2em;
465 }
465 }
466 h3 {
466 h3 {
467 color: @blue;
467 color: @blue;
468 line-height: 1.4em;
468 line-height: 1.4em;
469 margin: 30px 0 15px 0;
469 margin: 30px 0 15px 0;
470 font-size: 1em;
470 font-size: 1em;
471 text-shadow: 0px 0px 0px @lightest;
471 text-shadow: 0px 0px 0px @lightest;
472 span { color: @medium }
472 span { color: @medium }
473 }
473 }
474 #example {
474 #example {
475 p {
475 p {
476 font-size: 18px;
476 font-size: 18px;
477 color: @blue;
477 color: @blue;
478 font-weight: bold;
478 font-weight: bold;
479 text-shadow: 0px 1px 1px @lightest;
479 text-shadow: 0px 1px 1px @lightest;
480 }
480 }
481 pre {
481 pre {
482 margin: 0;
482 margin: 0;
483 text-shadow: 0 -1px 1px @darkest;
483 text-shadow: 0 -1px 1px @darkest;
484 margin-top: 20px;
484 margin-top: 20px;
485 background-color: desaturate(@darkest, 8%);
485 background-color: desaturate(@darkest, 8%);
486 border: 0;
486 border: 0;
487 width: 450px;
487 width: 450px;
488 color: lighten(@lightest, 2%);
488 color: lighten(@lightest, 2%);
489 background-repeat: repeat;
489 background-repeat: repeat;
490 padding: 15px;
490 padding: 15px;
491 border: 1px dashed @lightest;
491 border: 1px dashed @lightest;
492 line-height: 15px;
492 line-height: 15px;
493 .box-shadow(0, 0px, 15px, 0.5);
493 .box-shadow(0, 0px, 15px, 0.5);
494 .code;
494 .code;
495 .border-radius(2px);
495 .border-radius(2px);
496 code .attribute { color: hsl(40, 50%, 70%) }
496 code .attribute { color: hsl(40, 50%, 70%) }
497 code .variable { color: hsl(120, 10%, 50%) }
497 code .variable { color: hsl(120, 10%, 50%) }
498 code .element { color: hsl(170, 20%, 50%) }
498 code .element { color: hsl(170, 20%, 50%) }
499
499
500 code .string, .regexp { color: hsl(75, 50%, 65%) }
500 code .string, .regexp { color: hsl(75, 50%, 65%) }
501 code .class { color: hsl(40, 40%, 60%); font-weight: normal }
501 code .class { color: hsl(40, 40%, 60%); font-weight: normal }
502 code .id { color: hsl(50, 40%, 60%); font-weight: normal }
502 code .id { color: hsl(50, 40%, 60%); font-weight: normal }
503 code .comment { color: rgba(255, 255, 255, 0.2) }
503 code .comment { color: rgba(255, 255, 255, 0.2) }
504 code .number, .color { color: hsl(10, 40%, 50%) }
504 code .number, .color { color: hsl(10, 40%, 50%) }
505 code .class, code .mixin, .special { color: hsl(190, 20%, 50%) }
505 code .class, code .mixin, .special { color: hsl(190, 20%, 50%) }
506 #time { color: #aaa }
506 #time { color: #aaa }
507 }
507 }
508 float: right;
508 float: right;
509 font-size: 12px;
509 font-size: 12px;
510 margin: 0;
510 margin: 0;
511 margin-top: 15px;
511 margin-top: 15px;
512 padding: 0;
512 padding: 0;
513 width: 500px;
513 width: 500px;
514 }
514 }
515 }
515 }
516
516
517
517
518 .page {
518 .page {
519 .content {
519 .content {
520 width: 870px;
520 width: 870px;
521 padding: 45px;
521 padding: 45px;
522 }
522 }
523 margin: 0 auto;
523 margin: 0 auto;
524 font-family: 'Georgia', serif;
524 font-family: 'Georgia', serif;
525 font-size: 18px;
525 font-size: 18px;
526 line-height: 26px;
526 line-height: 26px;
527 padding: 0 60px;
527 padding: 0 60px;
528 code {
528 code {
529 font-size: 16px;
529 font-size: 16px;
530 }
530 }
531 pre {
531 pre {
532 border-width: 1px;
532 border-width: 1px;
533 border-style: dashed;
533 border-style: dashed;
534 padding: 15px;
534 padding: 15px;
535 margin: 15px 0;
535 margin: 15px 0;
536 }
536 }
537 h1 {
537 h1 {
538 text-align: left;
538 text-align: left;
539 font-size: 40px;
539 font-size: 40px;
540 margin-top: 15px;
540 margin-top: 15px;
541 margin-bottom: 35px;
541 margin-bottom: 35px;
542 }
542 }
543 p + h1 { margin-top: 60px }
543 p + h1 { margin-top: 60px }
544 h2, h3 {
544 h2, h3 {
545 margin: 30px 0 15px 0;
545 margin: 30px 0 15px 0;
546 }
546 }
547 p + h2, pre + h2, code + h2 {
547 p + h2, pre + h2, code + h2 {
548 border-top: 6px solid rgba(255, 255, 255, 0.1);
548 border-top: 6px solid rgba(255, 255, 255, 0.1);
549 padding-top: 30px;
549 padding-top: 30px;
550 }
550 }
551 h3 {
551 h3 {
552 margin: 15px 0;
552 margin: 15px 0;
553 }
553 }
554 }
554 }
555
555
556
556
557 #docs {
557 #docs {
558 @bg: lighten(@light-blue, 5%);
558 @bg: lighten(@light-blue, 5%);
559 border-top: 2px solid lighten(@bg, 5%);
559 border-top: 2px solid lighten(@bg, 5%);
560 color: @blue;
560 color: @blue;
561 background-color: @light-blue;
561 background-color: @light-blue;
562 .box-shadow(0, -2px, 5px, 0.2);
562 .box-shadow(0, -2px, 5px, 0.2);
563
563
564 h1 {
564 h1 {
565 font-family: 'Droid Serif', 'Georgia', serif;
565 font-family: 'Droid Serif', 'Georgia', serif;
566 padding-top: 30px;
566 padding-top: 30px;
567 padding-left: 45px;
567 padding-left: 45px;
568 font-size: 44px;
568 font-size: 44px;
569 text-align: left;
569 text-align: left;
570 margin: 30px 0 !important;
570 margin: 30px 0 !important;
571 text-shadow: 0px 1px 1px @lightest;
571 text-shadow: 0px 1px 1px @lightest;
572 font-weight: bold;
572 font-weight: bold;
573 }
573 }
574 .content {
574 .content {
575 clear: both;
575 clear: both;
576 border-color: transparent;
576 border-color: transparent;
577 background-color: lighten(@light-blue, 25%);
577 background-color: lighten(@light-blue, 25%);
578 .box-shadow(0, 5px, 5px, 0.4);
578 .box-shadow(0, 5px, 5px, 0.4);
579 }
579 }
580 pre {
580 pre {
581 @background: lighten(@bg, 30%);
581 @background: lighten(@bg, 30%);
582 color: lighten(@blue, 10%);
582 color: lighten(@blue, 10%);
583 background-color: @background;
583 background-color: @background;
584 border-color: lighten(@light-blue, 25%);
584 border-color: lighten(@light-blue, 25%);
585 border-width: 2px;
585 border-width: 2px;
586 code .attribute { color: hsl(40, 50%, 30%) }
586 code .attribute { color: hsl(40, 50%, 30%) }
587 code .variable { color: hsl(120, 10%, 30%) }
587 code .variable { color: hsl(120, 10%, 30%) }
588 code .element { color: hsl(170, 20%, 30%) }
588 code .element { color: hsl(170, 20%, 30%) }
589
589
590 code .string, .regexp { color: hsl(75, 50%, 35%) }
590 code .string, .regexp { color: hsl(75, 50%, 35%) }
591 code .class { color: hsl(40, 40%, 30%); font-weight: normal }
591 code .class { color: hsl(40, 40%, 30%); font-weight: normal }
592 code .id { color: hsl(50, 40%, 30%); font-weight: normal }
592 code .id { color: hsl(50, 40%, 30%); font-weight: normal }
593 code .comment { color: rgba(0, 0, 0, 0.4) }
593 code .comment { color: rgba(0, 0, 0, 0.4) }
594 code .number, .color { color: hsl(10, 40%, 30%) }
594 code .number, .color { color: hsl(10, 40%, 30%) }
595 code .class, code .mixin, .special { color: hsl(190, 20%, 30%) }
595 code .class, code .mixin, .special { color: hsl(190, 20%, 30%) }
596 }
596 }
597 pre code { font-size: 15px }
597 pre code { font-size: 15px }
598 p + h2, pre + h2, code + h2 { border-top-color: rgba(0, 0, 0, 0.1) }
598 p + h2, pre + h2, code + h2 { border-top-color: rgba(0, 0, 0, 0.1) }
599 }
599 }
600
600
601 td {
601 td {
602 padding-right: 30px;
602 padding-right: 30px;
603 }
603 }
604 #synopsis {
604 #synopsis {
605 .box-shadow(0, 5px, 5px, 0.2);
605 .box-shadow(0, 5px, 5px, 0.2);
606 }
606 }
607 #synopsis, #about {
607 #synopsis, #about {
608 h2 {
608 h2 {
609 font-size: 30px;
609 font-size: 30px;
610 padding: 10px 0;
610 padding: 10px 0;
611 }
611 }
612 h1 + h2 {
612 h1 + h2 {
613 margin-top: 15px;
613 margin-top: 15px;
614 }
614 }
615 h3 { font-size: 22px }
615 h3 { font-size: 22px }
616
616
617 .code-example {
617 .code-example {
618 border-spacing: 0;
618 border-spacing: 0;
619 border-width: 1px;
619 border-width: 1px;
620 border-style: dashed;
620 border-style: dashed;
621 padding: 0;
621 padding: 0;
622 pre { border: 0; margin: 0 }
622 pre { border: 0; margin: 0 }
623 td {
623 td {
624 border: 0;
624 border: 0;
625 margin: 0;
625 margin: 0;
626 background-color: desaturate(darken(@darkest, 5%), 20%);
626 background-color: desaturate(darken(@darkest, 5%), 20%);
627 vertical-align: top;
627 vertical-align: top;
628 padding: 0;
628 padding: 0;
629 }
629 }
630 tr { padding: 0 }
630 tr { padding: 0 }
631 }
631 }
632 .css-output {
632 .css-output {
633 td {
633 td {
634 border-left: 0;
634 border-left: 0;
635 }
635 }
636 }
636 }
637 .less-example {
637 .less-example {
638 //border-right: 1px dotted rgba(255, 255, 255, 0.5) !important;
638 //border-right: 1px dotted rgba(255, 255, 255, 0.5) !important;
639 }
639 }
640 .css-output, .less-example {
640 .css-output, .less-example {
641 width: 390px;
641 width: 390px;
642 }
642 }
643 pre {
643 pre {
644 padding: 20px;
644 padding: 20px;
645 line-height: 20px;
645 line-height: 20px;
646 font-size: 14px;
646 font-size: 14px;
647 }
647 }
648 }
648 }
649 #about, #synopsis, #guide {
649 #about, #synopsis, #guide {
650 a {
650 a {
651 text-decoration: none;
651 text-decoration: none;
652 color: @light-yellow;
652 color: @light-yellow;
653 border-bottom: 1px dashed rgba(255, 255, 255, 0.2);
653 border-bottom: 1px dashed rgba(255, 255, 255, 0.2);
654 &:hover {
654 &:hover {
655 text-decoration: none;
655 text-decoration: none;
656 border-bottom: 1px dashed @light-yellow;
656 border-bottom: 1px dashed @light-yellow;
657 }
657 }
658 }
658 }
659 @bg: desaturate(darken(@darkest, 5%), 20%);
659 @bg: desaturate(darken(@darkest, 5%), 20%);
660 text-shadow: 0 -1px 1px lighten(@bg, 5%);
660 text-shadow: 0 -1px 1px lighten(@bg, 5%);
661 color: @highlight;
661 color: @highlight;
662 background-color: @bg;
662 background-color: @bg;
663 .content {
663 .content {
664 background-color: desaturate(@darkest, 20%);
664 background-color: desaturate(@darkest, 20%);
665 clear: both;
665 clear: both;
666 .box-shadow(0, 5px, 5px, 0.4);
666 .box-shadow(0, 5px, 5px, 0.4);
667 }
667 }
668 h1, h2, h3 {
668 h1, h2, h3 {
669 color: @dark-yellow;
669 color: @dark-yellow;
670 }
670 }
671 pre {
671 pre {
672 code .attribute { color: hsl(40, 50%, 70%) }
672 code .attribute { color: hsl(40, 50%, 70%) }
673 code .variable { color: hsl(120, 10%, 50%) }
673 code .variable { color: hsl(120, 10%, 50%) }
674 code .element { color: hsl(170, 20%, 50%) }
674 code .element { color: hsl(170, 20%, 50%) }
675
675
676 code .string, .regexp { color: hsl(75, 50%, 65%) }
676 code .string, .regexp { color: hsl(75, 50%, 65%) }
677 code .class { color: hsl(40, 40%, 60%); font-weight: normal }
677 code .class { color: hsl(40, 40%, 60%); font-weight: normal }
678 code .id { color: hsl(50, 40%, 60%); font-weight: normal }
678 code .id { color: hsl(50, 40%, 60%); font-weight: normal }
679 code .comment { color: rgba(255, 255, 255, 0.2) }
679 code .comment { color: rgba(255, 255, 255, 0.2) }
680 code .number, .color { color: hsl(10, 40%, 50%) }
680 code .number, .color { color: hsl(10, 40%, 50%) }
681 code .class, code .mixin, .special { color: hsl(190, 20%, 50%) }
681 code .class, code .mixin, .special { color: hsl(190, 20%, 50%) }
682 background-color: @bg;
682 background-color: @bg;
683 border-color: darken(@light-yellow, 5%);
683 border-color: darken(@light-yellow, 5%);
684 }
684 }
685 code {
685 code {
686 color: darken(@dark-yellow, 5%);
686 color: darken(@dark-yellow, 5%);
687 .string, .regexp { color: desaturate(@light-blue, 15%) }
687 .string, .regexp { color: desaturate(@light-blue, 15%) }
688 .keyword { color: hsl(40, 40%, 60%); font-weight: normal }
688 .keyword { color: hsl(40, 40%, 60%); font-weight: normal }
689 .comment { color: rgba(255, 255, 255, 0.2) }
689 .comment { color: rgba(255, 255, 255, 0.2) }
690 .number { color: lighten(@blue, 10%) }
690 .number { color: lighten(@blue, 10%) }
691 .class, .special { color: hsl(190, 20%, 50%) }
691 .class, .special { color: hsl(190, 20%, 50%) }
692 }
692 }
693 }
693 }
694 #guide {
694 #guide {
695 background-color: @darkest;
695 background-color: @darkest;
696 .content {
696 .content {
697 background-color: transparent;
697 background-color: transparent;
698 }
698 }
699
699
700 }
700 }
701
701
702 #about {
702 #about {
703 background-color: @darkest !important;
703 background-color: @darkest !important;
704 .content {
704 .content {
705 background-color: desaturate(lighten(@darkest, 3%), 5%);
705 background-color: desaturate(lighten(@darkest, 3%), 5%);
706 }
706 }
707 }
707 }
708 #synopsis {
708 #synopsis {
709 background-color: desaturate(lighten(@darkest, 3%), 5%) !important;
709 background-color: desaturate(lighten(@darkest, 3%), 5%) !important;
710 .content {
710 .content {
711 background-color: desaturate(lighten(@darkest, 3%), 5%);
711 background-color: desaturate(lighten(@darkest, 3%), 5%);
712 }
712 }
713 pre {}
713 pre {}
714 }
714 }
715 #synopsis, #guide {
715 #synopsis, #guide {
716 .content {
716 .content {
717 .box-shadow(0, 0px, 0px, 0.0);
717 .box-shadow(0, 0px, 0px, 0.0);
718 }
718 }
719 }
719 }
720 #about footer {
720 #about footer {
721 margin-top: 30px;
721 margin-top: 30px;
722 padding-top: 30px;
722 padding-top: 30px;
723 border-top: 6px solid rgba(0, 0, 0, 0.1);
723 border-top: 6px solid rgba(0, 0, 0, 0.1);
724 text-align: center;
724 text-align: center;
725 font-size: 16px;
725 font-size: 16px;
726 color: rgba(255, 255, 255, 0.35);
726 color: rgba(255, 255, 255, 0.35);
727 #copy { font-size: 12px }
727 #copy { font-size: 12px }
728 text-shadow: -1px -1px 1px rgba(0, 0, 0, 0.02);
728 text-shadow: -1px -1px 1px rgba(0, 0, 0, 0.02);
729 }
729 }
730 </textarea></form>
730 </textarea></form>
731 <script>
731 <script>
732 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
732 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
733 theme: "lesser-dark",
733 theme: "lesser-dark",
734 lineNumbers : true,
734 lineNumbers : true,
735 matchBrackets : true
735 matchBrackets : true
736 });
736 });
737 </script>
737 </script>
738
738
739 <p><strong>MIME types defined:</strong> <code>text/x-less</code>, <code>text/css</code> (if not previously defined).</p>
739 <p><strong>MIME types defined:</strong> <code>text/x-less</code>, <code>text/css</code> (if not previously defined).</p>
740 </body>
740 </body>
741 </html>
741 </html>
@@ -1,74 +1,74 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: Lua mode</title>
5 <title>CodeMirror: Lua mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../addon/edit/matchbrackets.js"></script>
7 <script src="../../addon/edit/matchbrackets.js"></script>
8 <script src="../../lib/codemirror.js"></script>
8 <script src="../../lib/codemirror.js"></script>
9 <script src="lua.js"></script>
9 <script src="lua.js"></script>
10 <link rel="stylesheet" href="../../theme/neat.css">
10 <link rel="stylesheet" href="../../theme/neat.css">
11 <style>.CodeMirror {border: 1px solid black;}</style>
11 <style>.CodeMirror {border: 1px solid black;}</style>
12 <link rel="stylesheet" href="../../doc/docs.css">
12 <link rel="stylesheet" href="../../doc/docs.css">
13 </head>
13 </head>
14 <body>
14 <body>
15 <h1>CodeMirror: Lua mode</h1>
15 <h1>CodeMirror: Lua mode</h1>
16 <form><textarea id="code" name="code">
16 <form><textarea id="code" name="code">
17 --[[
17 --[[
18 example useless code to show lua syntax highlighting
18 example useless code to show lua syntax highlighting
19 this is multiline comment
19 this is multiline comment
20 ]]
20 ]]
21
21
22 function blahblahblah(x)
22 function blahblahblah(x)
23
23
24 local table = {
24 local table = {
25 "asd" = 123,
25 "asd" = 123,
26 "x" = 0.34,
26 "x" = 0.34,
27 }
27 }
28 if x ~= 3 then
28 if x ~= 3 then
29 print( x )
29 print( x )
30 elseif x == "string"
30 elseif x == "string"
31 my_custom_function( 0x34 )
31 my_custom_function( 0x34 )
32 else
32 else
33 unknown_function( "some string" )
33 unknown_function( "some string" )
34 end
34 end
35
35
36 --single line comment
36 --single line comment
37
37
38 end
38 end
39
39
40 function blablabla3()
40 function blablabla3()
41
41
42 for k,v in ipairs( table ) do
42 for k,v in ipairs( table ) do
43 --abcde..
43 --abcde..
44 y=[=[
44 y=[=[
45 x=[[
45 x=[[
46 x is a multi line string
46 x is a multi line string
47 ]]
47 ]]
48 but its definition is iside a highest level string!
48 but its definition is iside a highest level string!
49 ]=]
49 ]=]
50 print(" \"\" ")
50 print(" \"\" ")
51
51
52 s = math.sin( x )
52 s = math.sin( x )
53 end
53 end
54
54
55 end
55 end
56 </textarea></form>
56 </textarea></form>
57 <script>
57 <script>
58 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
58 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
59 tabMode: "indent",
59 tabMode: "indent",
60 matchBrackets: true,
60 matchBrackets: true,
61 theme: "neat"
61 theme: "neat"
62 });
62 });
63 </script>
63 </script>
64
64
65 <p>Loosely based on Franciszek
65 <p>Loosely based on Franciszek
66 Wawrzak's <a href="http://codemirror.net/1/contrib/lua">CodeMirror
66 Wawrzak's <a href="http://codemirror.net/1/contrib/lua">CodeMirror
67 1 mode</a>. One configuration parameter is
67 1 mode</a>. One configuration parameter is
68 supported, <code>specials</code>, to which you can provide an
68 supported, <code>specials</code>, to which you can provide an
69 array of strings to have those identifiers highlighted with
69 array of strings to have those identifiers highlighted with
70 the <code>lua-special</code> style.</p>
70 the <code>lua-special</code> style.</p>
71 <p><strong>MIME types defined:</strong> <code>text/x-lua</code>.</p>
71 <p><strong>MIME types defined:</strong> <code>text/x-lua</code>.</p>
72
72
73 </body>
73 </body>
74 </html>
74 </html>
@@ -1,344 +1,344 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: Markdown mode</title>
5 <title>CodeMirror: Markdown mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="../../addon/edit/continuelist.js"></script>
8 <script src="../../addon/edit/continuelist.js"></script>
9 <script src="../xml/xml.js"></script>
9 <script src="../xml/xml.js"></script>
10 <script src="markdown.js"></script>
10 <script src="markdown.js"></script>
11 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
11 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
12 <link rel="stylesheet" href="../../doc/docs.css">
12 <link rel="stylesheet" href="../../doc/docs.css">
13 </head>
13 </head>
14 <body>
14 <body>
15 <h1>CodeMirror: Markdown mode</h1>
15 <h1>CodeMirror: Markdown mode</h1>
16
16
17 <!-- source: http://daringfireball.net/projects/markdown/basics.text -->
17 <!-- source: http://daringfireball.net/projects/markdown/basics.text -->
18 <form><textarea id="code" name="code">
18 <form><textarea id="code" name="code">
19 Markdown: Basics
19 Markdown: Basics
20 ================
20 ================
21
21
22 &lt;ul id="ProjectSubmenu"&gt;
22 &lt;ul id="ProjectSubmenu"&gt;
23 &lt;li&gt;&lt;a href="/projects/markdown/" title="Markdown Project Page"&gt;Main&lt;/a&gt;&lt;/li&gt;
23 &lt;li&gt;&lt;a href="/projects/markdown/" title="Markdown Project Page"&gt;Main&lt;/a&gt;&lt;/li&gt;
24 &lt;li&gt;&lt;a class="selected" title="Markdown Basics"&gt;Basics&lt;/a&gt;&lt;/li&gt;
24 &lt;li&gt;&lt;a class="selected" title="Markdown Basics"&gt;Basics&lt;/a&gt;&lt;/li&gt;
25 &lt;li&gt;&lt;a href="/projects/markdown/syntax" title="Markdown Syntax Documentation"&gt;Syntax&lt;/a&gt;&lt;/li&gt;
25 &lt;li&gt;&lt;a href="/projects/markdown/syntax" title="Markdown Syntax Documentation"&gt;Syntax&lt;/a&gt;&lt;/li&gt;
26 &lt;li&gt;&lt;a href="/projects/markdown/license" title="Pricing and License Information"&gt;License&lt;/a&gt;&lt;/li&gt;
26 &lt;li&gt;&lt;a href="/projects/markdown/license" title="Pricing and License Information"&gt;License&lt;/a&gt;&lt;/li&gt;
27 &lt;li&gt;&lt;a href="/projects/markdown/dingus" title="Online Markdown Web Form"&gt;Dingus&lt;/a&gt;&lt;/li&gt;
27 &lt;li&gt;&lt;a href="/projects/markdown/dingus" title="Online Markdown Web Form"&gt;Dingus&lt;/a&gt;&lt;/li&gt;
28 &lt;/ul&gt;
28 &lt;/ul&gt;
29
29
30
30
31 Getting the Gist of Markdown's Formatting Syntax
31 Getting the Gist of Markdown's Formatting Syntax
32 ------------------------------------------------
32 ------------------------------------------------
33
33
34 This page offers a brief overview of what it's like to use Markdown.
34 This page offers a brief overview of what it's like to use Markdown.
35 The [syntax page] [s] provides complete, detailed documentation for
35 The [syntax page] [s] provides complete, detailed documentation for
36 every feature, but Markdown should be very easy to pick up simply by
36 every feature, but Markdown should be very easy to pick up simply by
37 looking at a few examples of it in action. The examples on this page
37 looking at a few examples of it in action. The examples on this page
38 are written in a before/after style, showing example syntax and the
38 are written in a before/after style, showing example syntax and the
39 HTML output produced by Markdown.
39 HTML output produced by Markdown.
40
40
41 It's also helpful to simply try Markdown out; the [Dingus] [d] is a
41 It's also helpful to simply try Markdown out; the [Dingus] [d] is a
42 web application that allows you type your own Markdown-formatted text
42 web application that allows you type your own Markdown-formatted text
43 and translate it to XHTML.
43 and translate it to XHTML.
44
44
45 **Note:** This document is itself written using Markdown; you
45 **Note:** This document is itself written using Markdown; you
46 can [see the source for it by adding '.text' to the URL] [src].
46 can [see the source for it by adding '.text' to the URL] [src].
47
47
48 [s]: /projects/markdown/syntax "Markdown Syntax"
48 [s]: /projects/markdown/syntax "Markdown Syntax"
49 [d]: /projects/markdown/dingus "Markdown Dingus"
49 [d]: /projects/markdown/dingus "Markdown Dingus"
50 [src]: /projects/markdown/basics.text
50 [src]: /projects/markdown/basics.text
51
51
52
52
53 ## Paragraphs, Headers, Blockquotes ##
53 ## Paragraphs, Headers, Blockquotes ##
54
54
55 A paragraph is simply one or more consecutive lines of text, separated
55 A paragraph is simply one or more consecutive lines of text, separated
56 by one or more blank lines. (A blank line is any line that looks like
56 by one or more blank lines. (A blank line is any line that looks like
57 a blank line -- a line containing nothing but spaces or tabs is
57 a blank line -- a line containing nothing but spaces or tabs is
58 considered blank.) Normal paragraphs should not be indented with
58 considered blank.) Normal paragraphs should not be indented with
59 spaces or tabs.
59 spaces or tabs.
60
60
61 Markdown offers two styles of headers: *Setext* and *atx*.
61 Markdown offers two styles of headers: *Setext* and *atx*.
62 Setext-style headers for `&lt;h1&gt;` and `&lt;h2&gt;` are created by
62 Setext-style headers for `&lt;h1&gt;` and `&lt;h2&gt;` are created by
63 "underlining" with equal signs (`=`) and hyphens (`-`), respectively.
63 "underlining" with equal signs (`=`) and hyphens (`-`), respectively.
64 To create an atx-style header, you put 1-6 hash marks (`#`) at the
64 To create an atx-style header, you put 1-6 hash marks (`#`) at the
65 beginning of the line -- the number of hashes equals the resulting
65 beginning of the line -- the number of hashes equals the resulting
66 HTML header level.
66 HTML header level.
67
67
68 Blockquotes are indicated using email-style '`&gt;`' angle brackets.
68 Blockquotes are indicated using email-style '`&gt;`' angle brackets.
69
69
70 Markdown:
70 Markdown:
71
71
72 A First Level Header
72 A First Level Header
73 ====================
73 ====================
74
74
75 A Second Level Header
75 A Second Level Header
76 ---------------------
76 ---------------------
77
77
78 Now is the time for all good men to come to
78 Now is the time for all good men to come to
79 the aid of their country. This is just a
79 the aid of their country. This is just a
80 regular paragraph.
80 regular paragraph.
81
81
82 The quick brown fox jumped over the lazy
82 The quick brown fox jumped over the lazy
83 dog's back.
83 dog's back.
84
84
85 ### Header 3
85 ### Header 3
86
86
87 &gt; This is a blockquote.
87 &gt; This is a blockquote.
88 &gt;
88 &gt;
89 &gt; This is the second paragraph in the blockquote.
89 &gt; This is the second paragraph in the blockquote.
90 &gt;
90 &gt;
91 &gt; ## This is an H2 in a blockquote
91 &gt; ## This is an H2 in a blockquote
92
92
93
93
94 Output:
94 Output:
95
95
96 &lt;h1&gt;A First Level Header&lt;/h1&gt;
96 &lt;h1&gt;A First Level Header&lt;/h1&gt;
97
97
98 &lt;h2&gt;A Second Level Header&lt;/h2&gt;
98 &lt;h2&gt;A Second Level Header&lt;/h2&gt;
99
99
100 &lt;p&gt;Now is the time for all good men to come to
100 &lt;p&gt;Now is the time for all good men to come to
101 the aid of their country. This is just a
101 the aid of their country. This is just a
102 regular paragraph.&lt;/p&gt;
102 regular paragraph.&lt;/p&gt;
103
103
104 &lt;p&gt;The quick brown fox jumped over the lazy
104 &lt;p&gt;The quick brown fox jumped over the lazy
105 dog's back.&lt;/p&gt;
105 dog's back.&lt;/p&gt;
106
106
107 &lt;h3&gt;Header 3&lt;/h3&gt;
107 &lt;h3&gt;Header 3&lt;/h3&gt;
108
108
109 &lt;blockquote&gt;
109 &lt;blockquote&gt;
110 &lt;p&gt;This is a blockquote.&lt;/p&gt;
110 &lt;p&gt;This is a blockquote.&lt;/p&gt;
111
111
112 &lt;p&gt;This is the second paragraph in the blockquote.&lt;/p&gt;
112 &lt;p&gt;This is the second paragraph in the blockquote.&lt;/p&gt;
113
113
114 &lt;h2&gt;This is an H2 in a blockquote&lt;/h2&gt;
114 &lt;h2&gt;This is an H2 in a blockquote&lt;/h2&gt;
115 &lt;/blockquote&gt;
115 &lt;/blockquote&gt;
116
116
117
117
118
118
119 ### Phrase Emphasis ###
119 ### Phrase Emphasis ###
120
120
121 Markdown uses asterisks and underscores to indicate spans of emphasis.
121 Markdown uses asterisks and underscores to indicate spans of emphasis.
122
122
123 Markdown:
123 Markdown:
124
124
125 Some of these words *are emphasized*.
125 Some of these words *are emphasized*.
126 Some of these words _are emphasized also_.
126 Some of these words _are emphasized also_.
127
127
128 Use two asterisks for **strong emphasis**.
128 Use two asterisks for **strong emphasis**.
129 Or, if you prefer, __use two underscores instead__.
129 Or, if you prefer, __use two underscores instead__.
130
130
131 Output:
131 Output:
132
132
133 &lt;p&gt;Some of these words &lt;em&gt;are emphasized&lt;/em&gt;.
133 &lt;p&gt;Some of these words &lt;em&gt;are emphasized&lt;/em&gt;.
134 Some of these words &lt;em&gt;are emphasized also&lt;/em&gt;.&lt;/p&gt;
134 Some of these words &lt;em&gt;are emphasized also&lt;/em&gt;.&lt;/p&gt;
135
135
136 &lt;p&gt;Use two asterisks for &lt;strong&gt;strong emphasis&lt;/strong&gt;.
136 &lt;p&gt;Use two asterisks for &lt;strong&gt;strong emphasis&lt;/strong&gt;.
137 Or, if you prefer, &lt;strong&gt;use two underscores instead&lt;/strong&gt;.&lt;/p&gt;
137 Or, if you prefer, &lt;strong&gt;use two underscores instead&lt;/strong&gt;.&lt;/p&gt;
138
138
139
139
140
140
141 ## Lists ##
141 ## Lists ##
142
142
143 Unordered (bulleted) lists use asterisks, pluses, and hyphens (`*`,
143 Unordered (bulleted) lists use asterisks, pluses, and hyphens (`*`,
144 `+`, and `-`) as list markers. These three markers are
144 `+`, and `-`) as list markers. These three markers are
145 interchangable; this:
145 interchangable; this:
146
146
147 * Candy.
147 * Candy.
148 * Gum.
148 * Gum.
149 * Booze.
149 * Booze.
150
150
151 this:
151 this:
152
152
153 + Candy.
153 + Candy.
154 + Gum.
154 + Gum.
155 + Booze.
155 + Booze.
156
156
157 and this:
157 and this:
158
158
159 - Candy.
159 - Candy.
160 - Gum.
160 - Gum.
161 - Booze.
161 - Booze.
162
162
163 all produce the same output:
163 all produce the same output:
164
164
165 &lt;ul&gt;
165 &lt;ul&gt;
166 &lt;li&gt;Candy.&lt;/li&gt;
166 &lt;li&gt;Candy.&lt;/li&gt;
167 &lt;li&gt;Gum.&lt;/li&gt;
167 &lt;li&gt;Gum.&lt;/li&gt;
168 &lt;li&gt;Booze.&lt;/li&gt;
168 &lt;li&gt;Booze.&lt;/li&gt;
169 &lt;/ul&gt;
169 &lt;/ul&gt;
170
170
171 Ordered (numbered) lists use regular numbers, followed by periods, as
171 Ordered (numbered) lists use regular numbers, followed by periods, as
172 list markers:
172 list markers:
173
173
174 1. Red
174 1. Red
175 2. Green
175 2. Green
176 3. Blue
176 3. Blue
177
177
178 Output:
178 Output:
179
179
180 &lt;ol&gt;
180 &lt;ol&gt;
181 &lt;li&gt;Red&lt;/li&gt;
181 &lt;li&gt;Red&lt;/li&gt;
182 &lt;li&gt;Green&lt;/li&gt;
182 &lt;li&gt;Green&lt;/li&gt;
183 &lt;li&gt;Blue&lt;/li&gt;
183 &lt;li&gt;Blue&lt;/li&gt;
184 &lt;/ol&gt;
184 &lt;/ol&gt;
185
185
186 If you put blank lines between items, you'll get `&lt;p&gt;` tags for the
186 If you put blank lines between items, you'll get `&lt;p&gt;` tags for the
187 list item text. You can create multi-paragraph list items by indenting
187 list item text. You can create multi-paragraph list items by indenting
188 the paragraphs by 4 spaces or 1 tab:
188 the paragraphs by 4 spaces or 1 tab:
189
189
190 * A list item.
190 * A list item.
191
191
192 With multiple paragraphs.
192 With multiple paragraphs.
193
193
194 * Another item in the list.
194 * Another item in the list.
195
195
196 Output:
196 Output:
197
197
198 &lt;ul&gt;
198 &lt;ul&gt;
199 &lt;li&gt;&lt;p&gt;A list item.&lt;/p&gt;
199 &lt;li&gt;&lt;p&gt;A list item.&lt;/p&gt;
200 &lt;p&gt;With multiple paragraphs.&lt;/p&gt;&lt;/li&gt;
200 &lt;p&gt;With multiple paragraphs.&lt;/p&gt;&lt;/li&gt;
201 &lt;li&gt;&lt;p&gt;Another item in the list.&lt;/p&gt;&lt;/li&gt;
201 &lt;li&gt;&lt;p&gt;Another item in the list.&lt;/p&gt;&lt;/li&gt;
202 &lt;/ul&gt;
202 &lt;/ul&gt;
203
203
204
204
205
205
206 ### Links ###
206 ### Links ###
207
207
208 Markdown supports two styles for creating links: *inline* and
208 Markdown supports two styles for creating links: *inline* and
209 *reference*. With both styles, you use square brackets to delimit the
209 *reference*. With both styles, you use square brackets to delimit the
210 text you want to turn into a link.
210 text you want to turn into a link.
211
211
212 Inline-style links use parentheses immediately after the link text.
212 Inline-style links use parentheses immediately after the link text.
213 For example:
213 For example:
214
214
215 This is an [example link](http://example.com/).
215 This is an [example link](http://example.com/).
216
216
217 Output:
217 Output:
218
218
219 &lt;p&gt;This is an &lt;a href="http://example.com/"&gt;
219 &lt;p&gt;This is an &lt;a href="http://example.com/"&gt;
220 example link&lt;/a&gt;.&lt;/p&gt;
220 example link&lt;/a&gt;.&lt;/p&gt;
221
221
222 Optionally, you may include a title attribute in the parentheses:
222 Optionally, you may include a title attribute in the parentheses:
223
223
224 This is an [example link](http://example.com/ "With a Title").
224 This is an [example link](http://example.com/ "With a Title").
225
225
226 Output:
226 Output:
227
227
228 &lt;p&gt;This is an &lt;a href="http://example.com/" title="With a Title"&gt;
228 &lt;p&gt;This is an &lt;a href="http://example.com/" title="With a Title"&gt;
229 example link&lt;/a&gt;.&lt;/p&gt;
229 example link&lt;/a&gt;.&lt;/p&gt;
230
230
231 Reference-style links allow you to refer to your links by names, which
231 Reference-style links allow you to refer to your links by names, which
232 you define elsewhere in your document:
232 you define elsewhere in your document:
233
233
234 I get 10 times more traffic from [Google][1] than from
234 I get 10 times more traffic from [Google][1] than from
235 [Yahoo][2] or [MSN][3].
235 [Yahoo][2] or [MSN][3].
236
236
237 [1]: http://google.com/ "Google"
237 [1]: http://google.com/ "Google"
238 [2]: http://search.yahoo.com/ "Yahoo Search"
238 [2]: http://search.yahoo.com/ "Yahoo Search"
239 [3]: http://search.msn.com/ "MSN Search"
239 [3]: http://search.msn.com/ "MSN Search"
240
240
241 Output:
241 Output:
242
242
243 &lt;p&gt;I get 10 times more traffic from &lt;a href="http://google.com/"
243 &lt;p&gt;I get 10 times more traffic from &lt;a href="http://google.com/"
244 title="Google"&gt;Google&lt;/a&gt; than from &lt;a href="http://search.yahoo.com/"
244 title="Google"&gt;Google&lt;/a&gt; than from &lt;a href="http://search.yahoo.com/"
245 title="Yahoo Search"&gt;Yahoo&lt;/a&gt; or &lt;a href="http://search.msn.com/"
245 title="Yahoo Search"&gt;Yahoo&lt;/a&gt; or &lt;a href="http://search.msn.com/"
246 title="MSN Search"&gt;MSN&lt;/a&gt;.&lt;/p&gt;
246 title="MSN Search"&gt;MSN&lt;/a&gt;.&lt;/p&gt;
247
247
248 The title attribute is optional. Link names may contain letters,
248 The title attribute is optional. Link names may contain letters,
249 numbers and spaces, but are *not* case sensitive:
249 numbers and spaces, but are *not* case sensitive:
250
250
251 I start my morning with a cup of coffee and
251 I start my morning with a cup of coffee and
252 [The New York Times][NY Times].
252 [The New York Times][NY Times].
253
253
254 [ny times]: http://www.nytimes.com/
254 [ny times]: http://www.nytimes.com/
255
255
256 Output:
256 Output:
257
257
258 &lt;p&gt;I start my morning with a cup of coffee and
258 &lt;p&gt;I start my morning with a cup of coffee and
259 &lt;a href="http://www.nytimes.com/"&gt;The New York Times&lt;/a&gt;.&lt;/p&gt;
259 &lt;a href="http://www.nytimes.com/"&gt;The New York Times&lt;/a&gt;.&lt;/p&gt;
260
260
261
261
262 ### Images ###
262 ### Images ###
263
263
264 Image syntax is very much like link syntax.
264 Image syntax is very much like link syntax.
265
265
266 Inline (titles are optional):
266 Inline (titles are optional):
267
267
268 ![alt text](/path/to/img.jpg "Title")
268 ![alt text](/path/to/img.jpg "Title")
269
269
270 Reference-style:
270 Reference-style:
271
271
272 ![alt text][id]
272 ![alt text][id]
273
273
274 [id]: /path/to/img.jpg "Title"
274 [id]: /path/to/img.jpg "Title"
275
275
276 Both of the above examples produce the same output:
276 Both of the above examples produce the same output:
277
277
278 &lt;img src="/path/to/img.jpg" alt="alt text" title="Title" /&gt;
278 &lt;img src="/path/to/img.jpg" alt="alt text" title="Title" /&gt;
279
279
280
280
281
281
282 ### Code ###
282 ### Code ###
283
283
284 In a regular paragraph, you can create code span by wrapping text in
284 In a regular paragraph, you can create code span by wrapping text in
285 backtick quotes. Any ampersands (`&amp;`) and angle brackets (`&lt;` or
285 backtick quotes. Any ampersands (`&amp;`) and angle brackets (`&lt;` or
286 `&gt;`) will automatically be translated into HTML entities. This makes
286 `&gt;`) will automatically be translated into HTML entities. This makes
287 it easy to use Markdown to write about HTML example code:
287 it easy to use Markdown to write about HTML example code:
288
288
289 I strongly recommend against using any `&lt;blink&gt;` tags.
289 I strongly recommend against using any `&lt;blink&gt;` tags.
290
290
291 I wish SmartyPants used named entities like `&amp;mdash;`
291 I wish SmartyPants used named entities like `&amp;mdash;`
292 instead of decimal-encoded entites like `&amp;#8212;`.
292 instead of decimal-encoded entites like `&amp;#8212;`.
293
293
294 Output:
294 Output:
295
295
296 &lt;p&gt;I strongly recommend against using any
296 &lt;p&gt;I strongly recommend against using any
297 &lt;code&gt;&amp;lt;blink&amp;gt;&lt;/code&gt; tags.&lt;/p&gt;
297 &lt;code&gt;&amp;lt;blink&amp;gt;&lt;/code&gt; tags.&lt;/p&gt;
298
298
299 &lt;p&gt;I wish SmartyPants used named entities like
299 &lt;p&gt;I wish SmartyPants used named entities like
300 &lt;code&gt;&amp;amp;mdash;&lt;/code&gt; instead of decimal-encoded
300 &lt;code&gt;&amp;amp;mdash;&lt;/code&gt; instead of decimal-encoded
301 entites like &lt;code&gt;&amp;amp;#8212;&lt;/code&gt;.&lt;/p&gt;
301 entites like &lt;code&gt;&amp;amp;#8212;&lt;/code&gt;.&lt;/p&gt;
302
302
303
303
304 To specify an entire block of pre-formatted code, indent every line of
304 To specify an entire block of pre-formatted code, indent every line of
305 the block by 4 spaces or 1 tab. Just like with code spans, `&amp;`, `&lt;`,
305 the block by 4 spaces or 1 tab. Just like with code spans, `&amp;`, `&lt;`,
306 and `&gt;` characters will be escaped automatically.
306 and `&gt;` characters will be escaped automatically.
307
307
308 Markdown:
308 Markdown:
309
309
310 If you want your page to validate under XHTML 1.0 Strict,
310 If you want your page to validate under XHTML 1.0 Strict,
311 you've got to put paragraph tags in your blockquotes:
311 you've got to put paragraph tags in your blockquotes:
312
312
313 &lt;blockquote&gt;
313 &lt;blockquote&gt;
314 &lt;p&gt;For example.&lt;/p&gt;
314 &lt;p&gt;For example.&lt;/p&gt;
315 &lt;/blockquote&gt;
315 &lt;/blockquote&gt;
316
316
317 Output:
317 Output:
318
318
319 &lt;p&gt;If you want your page to validate under XHTML 1.0 Strict,
319 &lt;p&gt;If you want your page to validate under XHTML 1.0 Strict,
320 you've got to put paragraph tags in your blockquotes:&lt;/p&gt;
320 you've got to put paragraph tags in your blockquotes:&lt;/p&gt;
321
321
322 &lt;pre&gt;&lt;code&gt;&amp;lt;blockquote&amp;gt;
322 &lt;pre&gt;&lt;code&gt;&amp;lt;blockquote&amp;gt;
323 &amp;lt;p&amp;gt;For example.&amp;lt;/p&amp;gt;
323 &amp;lt;p&amp;gt;For example.&amp;lt;/p&amp;gt;
324 &amp;lt;/blockquote&amp;gt;
324 &amp;lt;/blockquote&amp;gt;
325 &lt;/code&gt;&lt;/pre&gt;
325 &lt;/code&gt;&lt;/pre&gt;
326 </textarea></form>
326 </textarea></form>
327
327
328 <script>
328 <script>
329 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
329 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
330 mode: 'markdown',
330 mode: 'markdown',
331 lineNumbers: true,
331 lineNumbers: true,
332 theme: "default",
332 theme: "default",
333 extraKeys: {"Enter": "newlineAndIndentContinueMarkdownList"}
333 extraKeys: {"Enter": "newlineAndIndentContinueMarkdownList"}
334 });
334 });
335 </script>
335 </script>
336
336
337 <p>Optionally depends on the XML mode for properly highlighted inline XML blocks.</p>
337 <p>Optionally depends on the XML mode for properly highlighted inline XML blocks.</p>
338
338
339 <p><strong>MIME types defined:</strong> <code>text/x-markdown</code>.</p>
339 <p><strong>MIME types defined:</strong> <code>text/x-markdown</code>.</p>
340
340
341 <p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#markdown_*">normal</a>, <a href="../../test/index.html#verbose,markdown_*">verbose</a>.</p>
341 <p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#markdown_*">normal</a>, <a href="../../test/index.html#verbose,markdown_*">verbose</a>.</p>
342
342
343 </body>
343 </body>
344 </html>
344 </html>
@@ -1,149 +1,149 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: mIRC mode</title>
5 <title>CodeMirror: mIRC mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="mirc.js"></script>
8 <script src="mirc.js"></script>
9 <link rel="stylesheet" href="../../theme/twilight.css">
9 <link rel="stylesheet" href="../../theme/twilight.css">
10 <style>.CodeMirror {border: 1px solid black;}</style>
10 <style>.CodeMirror {border: 1px solid black;}</style>
11 <link rel="stylesheet" href="../../doc/docs.css">
11 <link rel="stylesheet" href="../../doc/docs.css">
12 </head>
12 </head>
13 <body>
13 <body>
14 <h1>CodeMirror: mIRC mode</h1>
14 <h1>CodeMirror: mIRC mode</h1>
15 <form><textarea id="code" name="code">
15 <form><textarea id="code" name="code">
16 ;AKA Nick Tracker by Ford_Lawnmower irc.GeekShed.net #Script-Help
16 ;AKA Nick Tracker by Ford_Lawnmower irc.GeekShed.net #Script-Help
17 ;*****************************************************************************;
17 ;*****************************************************************************;
18 ;**Start Setup
18 ;**Start Setup
19 ;Change JoinDisplay, below, for On Join AKA Display. On = 1 - Off = 0
19 ;Change JoinDisplay, below, for On Join AKA Display. On = 1 - Off = 0
20 alias -l JoinDisplay { return 1 }
20 alias -l JoinDisplay { return 1 }
21 ;Change MaxNicks, below, to the number of nicknames you want to store for each hostmask. I wouldn't go over 400 with this ;/
21 ;Change MaxNicks, below, to the number of nicknames you want to store for each hostmask. I wouldn't go over 400 with this ;/
22 alias -l MaxNicks { return 20 }
22 alias -l MaxNicks { return 20 }
23 ;Change AKALogo, below, To the text you want displayed before each AKA result.
23 ;Change AKALogo, below, To the text you want displayed before each AKA result.
24 alias -l AKALogo { return 06 05A06K07A 06 }
24 alias -l AKALogo { return 06 05A06K07A 06 }
25 ;**End Setup
25 ;**End Setup
26 ;*****************************************************************************;
26 ;*****************************************************************************;
27 On *:Join:#: {
27 On *:Join:#: {
28 if ($nick == $me) { .timer 1 1 ialupdateCheck $chan }
28 if ($nick == $me) { .timer 1 1 ialupdateCheck $chan }
29 NickNamesAdd $nick $+($network,$wildsite)
29 NickNamesAdd $nick $+($network,$wildsite)
30 if ($JoinDisplay) { .timerNickNames $+ $nick 1 2 NickNames.display $nick $chan $network $wildsite }
30 if ($JoinDisplay) { .timerNickNames $+ $nick 1 2 NickNames.display $nick $chan $network $wildsite }
31 }
31 }
32 on *:Nick: { NickNamesAdd $newnick $+($network,$wildsite) $nick }
32 on *:Nick: { NickNamesAdd $newnick $+($network,$wildsite) $nick }
33 alias -l NickNames.display {
33 alias -l NickNames.display {
34 if ($gettok($hget(NickNames,$+($3,$4)),0,126) > 1) {
34 if ($gettok($hget(NickNames,$+($3,$4)),0,126) > 1) {
35 echo -g $2 $AKALogo $+(09,$1) $AKALogo 07 $mid($replace($hget(NickNames,$+($3,$4)),$chr(126),$chr(44)),2,-1)
35 echo -g $2 $AKALogo $+(09,$1) $AKALogo 07 $mid($replace($hget(NickNames,$+($3,$4)),$chr(126),$chr(44)),2,-1)
36 }
36 }
37 }
37 }
38 alias -l NickNamesAdd {
38 alias -l NickNamesAdd {
39 if ($hget(NickNames,$2)) {
39 if ($hget(NickNames,$2)) {
40 if (!$regex($hget(NickNames,$2),/~\Q $+ $replacecs($1,\E,\E\\E\Q) $+ \E~/i)) {
40 if (!$regex($hget(NickNames,$2),/~\Q $+ $replacecs($1,\E,\E\\E\Q) $+ \E~/i)) {
41 if ($gettok($hget(NickNames,$2),0,126) <= $MaxNicks) {
41 if ($gettok($hget(NickNames,$2),0,126) <= $MaxNicks) {
42 hadd NickNames $2 $+($hget(NickNames,$2),$1,~)
42 hadd NickNames $2 $+($hget(NickNames,$2),$1,~)
43 }
43 }
44 else {
44 else {
45 hadd NickNames $2 $+($mid($hget(NickNames,$2),$pos($hget(NickNames,$2),~,2)),$1,~)
45 hadd NickNames $2 $+($mid($hget(NickNames,$2),$pos($hget(NickNames,$2),~,2)),$1,~)
46 }
46 }
47 }
47 }
48 }
48 }
49 else {
49 else {
50 hadd -m NickNames $2 $+(~,$1,~,$iif($3,$+($3,~)))
50 hadd -m NickNames $2 $+(~,$1,~,$iif($3,$+($3,~)))
51 }
51 }
52 }
52 }
53 alias -l Fix.All.MindUser {
53 alias -l Fix.All.MindUser {
54 var %Fix.Count = $hfind(NickNames,/[^~]+[0-9]{4}~/,0,r).data
54 var %Fix.Count = $hfind(NickNames,/[^~]+[0-9]{4}~/,0,r).data
55 while (%Fix.Count) {
55 while (%Fix.Count) {
56 if ($Fix.MindUser($hget(NickNames,$hfind(NickNames,/[^~]+[0-9]{4}~/,%Fix.Count,r).data))) {
56 if ($Fix.MindUser($hget(NickNames,$hfind(NickNames,/[^~]+[0-9]{4}~/,%Fix.Count,r).data))) {
57 echo -ag Record %Fix.Count - $v1 - Was Cleaned
57 echo -ag Record %Fix.Count - $v1 - Was Cleaned
58 hadd NickNames $hfind(NickNames,/[^~]+[0-9]{4}~/,%Fix.Count,r).data $v1
58 hadd NickNames $hfind(NickNames,/[^~]+[0-9]{4}~/,%Fix.Count,r).data $v1
59 }
59 }
60 dec %Fix.Count
60 dec %Fix.Count
61 }
61 }
62 }
62 }
63 alias -l Fix.MindUser { return $regsubex($1,/[^~]+[0-9]{4}~/g,$null) }
63 alias -l Fix.MindUser { return $regsubex($1,/[^~]+[0-9]{4}~/g,$null) }
64 menu nicklist,query {
64 menu nicklist,query {
65 -
65 -
66 .AKA
66 .AKA
67 ..Check $$1: {
67 ..Check $$1: {
68 if ($gettok($hget(NickNames,$+($network,$address($1,2))),0,126) > 1) {
68 if ($gettok($hget(NickNames,$+($network,$address($1,2))),0,126) > 1) {
69 NickNames.display $1 $active $network $address($1,2)
69 NickNames.display $1 $active $network $address($1,2)
70 }
70 }
71 else { echo -ag $AKALogo $+(09,$1) 07has not been known by any other nicknames while I have been watching. }
71 else { echo -ag $AKALogo $+(09,$1) 07has not been known by any other nicknames while I have been watching. }
72 }
72 }
73 ..Cleanup $$1:hadd NickNames $+($network,$address($1,2)) $fix.minduser($hget(NickNames,$+($network,$address($1,2))))
73 ..Cleanup $$1:hadd NickNames $+($network,$address($1,2)) $fix.minduser($hget(NickNames,$+($network,$address($1,2))))
74 ..Clear $$1:hadd NickNames $+($network,$address($1,2)) $+(~,$1,~)
74 ..Clear $$1:hadd NickNames $+($network,$address($1,2)) $+(~,$1,~)
75 ..AKA Search Dialog:dialog $iif($dialog(AKA_Search),-v,-m) AKA_Search AKA_Search
75 ..AKA Search Dialog:dialog $iif($dialog(AKA_Search),-v,-m) AKA_Search AKA_Search
76 -
76 -
77 }
77 }
78 menu status,channel {
78 menu status,channel {
79 -
79 -
80 .AKA
80 .AKA
81 ..AKA Search Dialog:dialog $iif($dialog(AKA_Search),-v,-m) AKA_Search AKA_Search
81 ..AKA Search Dialog:dialog $iif($dialog(AKA_Search),-v,-m) AKA_Search AKA_Search
82 ..Clean All Records:Fix.All.Minduser
82 ..Clean All Records:Fix.All.Minduser
83 -
83 -
84 }
84 }
85 dialog AKA_Search {
85 dialog AKA_Search {
86 title "AKA Search Engine"
86 title "AKA Search Engine"
87 size -1 -1 206 221
87 size -1 -1 206 221
88 option dbu
88 option dbu
89 edit "", 1, 8 5 149 10, autohs
89 edit "", 1, 8 5 149 10, autohs
90 button "Search", 2, 163 4 32 12
90 button "Search", 2, 163 4 32 12
91 radio "Search HostMask", 4, 61 22 55 10
91 radio "Search HostMask", 4, 61 22 55 10
92 radio "Search Nicknames", 5, 123 22 56 10
92 radio "Search Nicknames", 5, 123 22 56 10
93 list 6, 8 38 190 169, sort extsel vsbar
93 list 6, 8 38 190 169, sort extsel vsbar
94 button "Check Selected", 7, 67 206 40 12
94 button "Check Selected", 7, 67 206 40 12
95 button "Close", 8, 160 206 38 12, cancel
95 button "Close", 8, 160 206 38 12, cancel
96 box "Search Type", 3, 11 17 183 18
96 box "Search Type", 3, 11 17 183 18
97 button "Copy to Clipboard", 9, 111 206 46 12
97 button "Copy to Clipboard", 9, 111 206 46 12
98 }
98 }
99 On *:Dialog:Aka_Search:init:*: { did -c $dname 5 }
99 On *:Dialog:Aka_Search:init:*: { did -c $dname 5 }
100 On *:Dialog:Aka_Search:Sclick:2,7,9: {
100 On *:Dialog:Aka_Search:Sclick:2,7,9: {
101 if ($did == 2) && ($did($dname,1)) {
101 if ($did == 2) && ($did($dname,1)) {
102 did -r $dname 6
102 did -r $dname 6
103 var %search $+(*,$v1,*), %type $iif($did($dname,5).state,data,item), %matches = $hfind(NickNames,%search,0,w). [ $+ [ %type ] ]
103 var %search $+(*,$v1,*), %type $iif($did($dname,5).state,data,item), %matches = $hfind(NickNames,%search,0,w). [ $+ [ %type ] ]
104 while (%matches) {
104 while (%matches) {
105 did -a $dname 6 $hfind(NickNames,%search,%matches,w). [ $+ [ %type ] ]
105 did -a $dname 6 $hfind(NickNames,%search,%matches,w). [ $+ [ %type ] ]
106 dec %matches
106 dec %matches
107 }
107 }
108 did -c $dname 6 1
108 did -c $dname 6 1
109 }
109 }
110 elseif ($did == 7) && ($did($dname,6).seltext) { echo -ga $AKALogo 07 $mid($replace($hget(NickNames,$v1),$chr(126),$chr(44)),2,-1) }
110 elseif ($did == 7) && ($did($dname,6).seltext) { echo -ga $AKALogo 07 $mid($replace($hget(NickNames,$v1),$chr(126),$chr(44)),2,-1) }
111 elseif ($did == 9) && ($did($dname,6).seltext) { clipboard $mid($v1,$pos($v1,*,1)) }
111 elseif ($did == 9) && ($did($dname,6).seltext) { clipboard $mid($v1,$pos($v1,*,1)) }
112 }
112 }
113 On *:Start:{
113 On *:Start:{
114 if (!$hget(NickNames)) { hmake NickNames 10 }
114 if (!$hget(NickNames)) { hmake NickNames 10 }
115 if ($isfile(NickNames.hsh)) { hload NickNames NickNames.hsh }
115 if ($isfile(NickNames.hsh)) { hload NickNames NickNames.hsh }
116 }
116 }
117 On *:Exit: { if ($hget(NickNames)) { hsave NickNames NickNames.hsh } }
117 On *:Exit: { if ($hget(NickNames)) { hsave NickNames NickNames.hsh } }
118 On *:Disconnect: { if ($hget(NickNames)) { hsave NickNames NickNames.hsh } }
118 On *:Disconnect: { if ($hget(NickNames)) { hsave NickNames NickNames.hsh } }
119 On *:Unload: { hfree NickNames }
119 On *:Unload: { hfree NickNames }
120 alias -l ialupdateCheck {
120 alias -l ialupdateCheck {
121 inc -z $+(%,ialupdateCheck,$network) $calc($nick($1,0) / 4)
121 inc -z $+(%,ialupdateCheck,$network) $calc($nick($1,0) / 4)
122 ;If your ial is already being updated on join .who $1 out.
122 ;If your ial is already being updated on join .who $1 out.
123 ;If you are using /names to update ial you will still need this line.
123 ;If you are using /names to update ial you will still need this line.
124 .who $1
124 .who $1
125 }
125 }
126 Raw 352:*: {
126 Raw 352:*: {
127 if ($($+(%,ialupdateCheck,$network),2)) haltdef
127 if ($($+(%,ialupdateCheck,$network),2)) haltdef
128 NickNamesAdd $6 $+($network,$address($6,2))
128 NickNamesAdd $6 $+($network,$address($6,2))
129 }
129 }
130 Raw 315:*: {
130 Raw 315:*: {
131 if ($($+(%,ialupdateCheck,$network),2)) haltdef
131 if ($($+(%,ialupdateCheck,$network),2)) haltdef
132 }
132 }
133
133
134 </textarea></form>
134 </textarea></form>
135 <script>
135 <script>
136 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
136 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
137 tabMode: "indent",
137 tabMode: "indent",
138 theme: "twilight",
138 theme: "twilight",
139 lineNumbers: true,
139 lineNumbers: true,
140 matchBrackets: true,
140 matchBrackets: true,
141 indentUnit: 4,
141 indentUnit: 4,
142 mode: "text/mirc"
142 mode: "text/mirc"
143 });
143 });
144 </script>
144 </script>
145
145
146 <p><strong>MIME types defined:</strong> <code>text/mirc</code>.</p>
146 <p><strong>MIME types defined:</strong> <code>text/mirc</code>.</p>
147
147
148 </body>
148 </body>
149 </html>
149 </html>
@@ -1,33 +1,33 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: NTriples mode</title>
5 <title>CodeMirror: NTriples mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="ntriples.js"></script>
8 <script src="ntriples.js"></script>
9 <link rel="stylesheet" href="../../doc/docs.css">
9 <link rel="stylesheet" href="../../doc/docs.css">
10 <style type="text/css">
10 <style type="text/css">
11 .CodeMirror {
11 .CodeMirror {
12 border: 1px solid #eee;
12 border: 1px solid #eee;
13 }
13 }
14 </style>
14 </style>
15 </head>
15 </head>
16 <body>
16 <body>
17 <h1>CodeMirror: NTriples mode</h1>
17 <h1>CodeMirror: NTriples mode</h1>
18 <form>
18 <form>
19 <textarea id="ntriples" name="ntriples">
19 <textarea id="ntriples" name="ntriples">
20 <http://Sub1> <http://pred1> <http://obj> .
20 <http://Sub1> <http://pred1> <http://obj> .
21 <http://Sub2> <http://pred2#an2> "literal 1" .
21 <http://Sub2> <http://pred2#an2> "literal 1" .
22 <http://Sub3#an3> <http://pred3> _:bnode3 .
22 <http://Sub3#an3> <http://pred3> _:bnode3 .
23 _:bnode4 <http://pred4> "literal 2"@lang .
23 _:bnode4 <http://pred4> "literal 2"@lang .
24 _:bnode5 <http://pred5> "literal 3"^^<http://type> .
24 _:bnode5 <http://pred5> "literal 3"^^<http://type> .
25 </textarea>
25 </textarea>
26 </form>
26 </form>
27
27
28 <script>
28 <script>
29 var editor = CodeMirror.fromTextArea(document.getElementById("ntriples"), {});
29 var editor = CodeMirror.fromTextArea(document.getElementById("ntriples"), {});
30 </script>
30 </script>
31 <p><strong>MIME types defined:</strong> <code>text/n-triples</code>.</p>
31 <p><strong>MIME types defined:</strong> <code>text/n-triples</code>.</p>
32 </body>
32 </body>
33 </html>
33 </html>
@@ -1,131 +1,131 b''
1 <!doctype html>
1 <!doctype html>
2 <meta charset=utf-8>
2 <meta charset=utf-8>
3 <title>CodeMirror: OCaml mode</title>
3 <title>CodeMirror: OCaml mode</title>
4
4
5 <link rel=stylesheet href=../../lib/codemirror.css>
5 <link rel=stylesheet href=../../lib/codemirror.css>
6 <link rel=stylesheet href=../../doc/docs.css>
6 <link rel=stylesheet href=../../doc/docs.css>
7
7
8 <style type=text/css>
8 <style type=text/css>
9 .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
9 .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
10 </style>
10 </style>
11
11
12 <script src=../../lib/codemirror.js></script>
12 <script src=../../lib/codemirror.js></script>
13 <script src=../../addon/edit/matchbrackets.js></script>
13 <script src=../../addon/edit/matchbrackets.js></script>
14 <script src=ocaml.js></script>
14 <script src=ocaml.js></script>
15
15
16 <h1>CodeMirror: OCaml mode</h1>
16 <h1>CodeMirror: OCaml mode</h1>
17
17
18 <textarea id=code>
18 <textarea id=code>
19 (* Summing a list of integers *)
19 (* Summing a list of integers *)
20 let rec sum xs =
20 let rec sum xs =
21 match xs with
21 match xs with
22 | [] -&gt; 0
22 | [] -&gt; 0
23 | x :: xs' -&gt; x + sum xs'
23 | x :: xs' -&gt; x + sum xs'
24
24
25 (* Quicksort *)
25 (* Quicksort *)
26 let rec qsort = function
26 let rec qsort = function
27 | [] -&gt; []
27 | [] -&gt; []
28 | pivot :: rest -&gt;
28 | pivot :: rest -&gt;
29 let is_less x = x &lt; pivot in
29 let is_less x = x &lt; pivot in
30 let left, right = List.partition is_less rest in
30 let left, right = List.partition is_less rest in
31 qsort left @ [pivot] @ qsort right
31 qsort left @ [pivot] @ qsort right
32
32
33 (* Fibonacci Sequence *)
33 (* Fibonacci Sequence *)
34 let rec fib_aux n a b =
34 let rec fib_aux n a b =
35 match n with
35 match n with
36 | 0 -&gt; a
36 | 0 -&gt; a
37 | _ -&gt; fib_aux (n - 1) (a + b) a
37 | _ -&gt; fib_aux (n - 1) (a + b) a
38 let fib n = fib_aux n 0 1
38 let fib n = fib_aux n 0 1
39
39
40 (* Birthday paradox *)
40 (* Birthday paradox *)
41 let year_size = 365.
41 let year_size = 365.
42
42
43 let rec birthday_paradox prob people =
43 let rec birthday_paradox prob people =
44 let prob' = (year_size -. float people) /. year_size *. prob in
44 let prob' = (year_size -. float people) /. year_size *. prob in
45 if prob' &lt; 0.5 then
45 if prob' &lt; 0.5 then
46 Printf.printf "answer = %d\n" (people+1)
46 Printf.printf "answer = %d\n" (people+1)
47 else
47 else
48 birthday_paradox prob' (people+1) ;;
48 birthday_paradox prob' (people+1) ;;
49
49
50 birthday_paradox 1.0 1
50 birthday_paradox 1.0 1
51
51
52 (* Church numerals *)
52 (* Church numerals *)
53 let zero f x = x
53 let zero f x = x
54 let succ n f x = f (n f x)
54 let succ n f x = f (n f x)
55 let one = succ zero
55 let one = succ zero
56 let two = succ (succ zero)
56 let two = succ (succ zero)
57 let add n1 n2 f x = n1 f (n2 f x)
57 let add n1 n2 f x = n1 f (n2 f x)
58 let to_string n = n (fun k -&gt; "S" ^ k) "0"
58 let to_string n = n (fun k -&gt; "S" ^ k) "0"
59 let _ = to_string (add (succ two) two)
59 let _ = to_string (add (succ two) two)
60
60
61 (* Elementary functions *)
61 (* Elementary functions *)
62 let square x = x * x;;
62 let square x = x * x;;
63 let rec fact x =
63 let rec fact x =
64 if x &lt;= 1 then 1 else x * fact (x - 1);;
64 if x &lt;= 1 then 1 else x * fact (x - 1);;
65
65
66 (* Automatic memory management *)
66 (* Automatic memory management *)
67 let l = 1 :: 2 :: 3 :: [];;
67 let l = 1 :: 2 :: 3 :: [];;
68 [1; 2; 3];;
68 [1; 2; 3];;
69 5 :: l;;
69 5 :: l;;
70
70
71 (* Polymorphism: sorting lists *)
71 (* Polymorphism: sorting lists *)
72 let rec sort = function
72 let rec sort = function
73 | [] -&gt; []
73 | [] -&gt; []
74 | x :: l -&gt; insert x (sort l)
74 | x :: l -&gt; insert x (sort l)
75
75
76 and insert elem = function
76 and insert elem = function
77 | [] -&gt; [elem]
77 | [] -&gt; [elem]
78 | x :: l -&gt;
78 | x :: l -&gt;
79 if elem &lt; x then elem :: x :: l else x :: insert elem l;;
79 if elem &lt; x then elem :: x :: l else x :: insert elem l;;
80
80
81 (* Imperative features *)
81 (* Imperative features *)
82 let add_polynom p1 p2 =
82 let add_polynom p1 p2 =
83 let n1 = Array.length p1
83 let n1 = Array.length p1
84 and n2 = Array.length p2 in
84 and n2 = Array.length p2 in
85 let result = Array.create (max n1 n2) 0 in
85 let result = Array.create (max n1 n2) 0 in
86 for i = 0 to n1 - 1 do result.(i) &lt;- p1.(i) done;
86 for i = 0 to n1 - 1 do result.(i) &lt;- p1.(i) done;
87 for i = 0 to n2 - 1 do result.(i) &lt;- result.(i) + p2.(i) done;
87 for i = 0 to n2 - 1 do result.(i) &lt;- result.(i) + p2.(i) done;
88 result;;
88 result;;
89 add_polynom [| 1; 2 |] [| 1; 2; 3 |];;
89 add_polynom [| 1; 2 |] [| 1; 2; 3 |];;
90
90
91 (* We may redefine fact using a reference cell and a for loop *)
91 (* We may redefine fact using a reference cell and a for loop *)
92 let fact n =
92 let fact n =
93 let result = ref 1 in
93 let result = ref 1 in
94 for i = 2 to n do
94 for i = 2 to n do
95 result := i * !result
95 result := i * !result
96 done;
96 done;
97 !result;;
97 !result;;
98 fact 5;;
98 fact 5;;
99
99
100 (* Triangle (graphics) *)
100 (* Triangle (graphics) *)
101 let () =
101 let () =
102 ignore( Glut.init Sys.argv );
102 ignore( Glut.init Sys.argv );
103 Glut.initDisplayMode ~double_buffer:true ();
103 Glut.initDisplayMode ~double_buffer:true ();
104 ignore (Glut.createWindow ~title:"OpenGL Demo");
104 ignore (Glut.createWindow ~title:"OpenGL Demo");
105 let angle t = 10. *. t *. t in
105 let angle t = 10. *. t *. t in
106 let render () =
106 let render () =
107 GlClear.clear [ `color ];
107 GlClear.clear [ `color ];
108 GlMat.load_identity ();
108 GlMat.load_identity ();
109 GlMat.rotate ~angle: (angle (Sys.time ())) ~z:1. ();
109 GlMat.rotate ~angle: (angle (Sys.time ())) ~z:1. ();
110 GlDraw.begins `triangles;
110 GlDraw.begins `triangles;
111 List.iter GlDraw.vertex2 [-1., -1.; 0., 1.; 1., -1.];
111 List.iter GlDraw.vertex2 [-1., -1.; 0., 1.; 1., -1.];
112 GlDraw.ends ();
112 GlDraw.ends ();
113 Glut.swapBuffers () in
113 Glut.swapBuffers () in
114 GlMat.mode `modelview;
114 GlMat.mode `modelview;
115 Glut.displayFunc ~cb:render;
115 Glut.displayFunc ~cb:render;
116 Glut.idleFunc ~cb:(Some Glut.postRedisplay);
116 Glut.idleFunc ~cb:(Some Glut.postRedisplay);
117 Glut.mainLoop ()
117 Glut.mainLoop ()
118
118
119 (* A Hundred Lines of Caml - http://caml.inria.fr/about/taste.en.html *)
119 (* A Hundred Lines of Caml - http://caml.inria.fr/about/taste.en.html *)
120 (* OCaml page on Wikipedia - http://en.wikipedia.org/wiki/OCaml *)
120 (* OCaml page on Wikipedia - http://en.wikipedia.org/wiki/OCaml *)
121 </textarea>
121 </textarea>
122
122
123 <script>
123 <script>
124 var editor = CodeMirror.fromTextArea(document.getElementById('code'), {
124 var editor = CodeMirror.fromTextArea(document.getElementById('code'), {
125 mode: 'ocaml',
125 mode: 'ocaml',
126 lineNumbers: true,
126 lineNumbers: true,
127 matchBrackets: true
127 matchBrackets: true
128 });
128 });
129 </script>
129 </script>
130
130
131 <p><strong>MIME types defined:</strong> <code>text/x-ocaml</code>.</p>
131 <p><strong>MIME types defined:</strong> <code>text/x-ocaml</code>.</p>
@@ -1,48 +1,48 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: Pascal mode</title>
5 <title>CodeMirror: Pascal mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="pascal.js"></script>
8 <script src="pascal.js"></script>
9 <link rel="stylesheet" href="../../doc/docs.css">
9 <link rel="stylesheet" href="../../doc/docs.css">
10 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
10 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
11 </head>
11 </head>
12 <body>
12 <body>
13 <h1>CodeMirror: Pascal mode</h1>
13 <h1>CodeMirror: Pascal mode</h1>
14
14
15 <div><textarea id="code" name="code">
15 <div><textarea id="code" name="code">
16 (* Example Pascal code *)
16 (* Example Pascal code *)
17
17
18 while a <> b do writeln('Waiting');
18 while a <> b do writeln('Waiting');
19
19
20 if a > b then
20 if a > b then
21 writeln('Condition met')
21 writeln('Condition met')
22 else
22 else
23 writeln('Condition not met');
23 writeln('Condition not met');
24
24
25 for i := 1 to 10 do
25 for i := 1 to 10 do
26 writeln('Iteration: ', i:1);
26 writeln('Iteration: ', i:1);
27
27
28 repeat
28 repeat
29 a := a + 1
29 a := a + 1
30 until a = 10;
30 until a = 10;
31
31
32 case i of
32 case i of
33 0: write('zero');
33 0: write('zero');
34 1: write('one');
34 1: write('one');
35 2: write('two')
35 2: write('two')
36 end;
36 end;
37 </textarea></div>
37 </textarea></div>
38
38
39 <script>
39 <script>
40 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
40 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
41 lineNumbers: true,
41 lineNumbers: true,
42 mode: "text/x-pascal"
42 mode: "text/x-pascal"
43 });
43 });
44 </script>
44 </script>
45
45
46 <p><strong>MIME types defined:</strong> <code>text/x-pascal</code>.</p>
46 <p><strong>MIME types defined:</strong> <code>text/x-pascal</code>.</p>
47 </body>
47 </body>
48 </html>
48 </html>
@@ -1,62 +1,62 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: Perl mode</title>
5 <title>CodeMirror: Perl mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="perl.js"></script>
8 <script src="perl.js"></script>
9 <link rel="stylesheet" href="../../doc/docs.css">
9 <link rel="stylesheet" href="../../doc/docs.css">
10 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
10 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
11 </head>
11 </head>
12 <body>
12 <body>
13 <h1>CodeMirror: Perl mode</h1>
13 <h1>CodeMirror: Perl mode</h1>
14
14
15 <div><textarea id="code" name="code">
15 <div><textarea id="code" name="code">
16 #!/usr/bin/perl
16 #!/usr/bin/perl
17
17
18 use Something qw(func1 func2);
18 use Something qw(func1 func2);
19
19
20 # strings
20 # strings
21 my $s1 = qq'single line';
21 my $s1 = qq'single line';
22 our $s2 = q(multi-
22 our $s2 = q(multi-
23 line);
23 line);
24
24
25 =item Something
25 =item Something
26 Example.
26 Example.
27 =cut
27 =cut
28
28
29 my $html=<<'HTML'
29 my $html=<<'HTML'
30 <html>
30 <html>
31 <title>hi!</title>
31 <title>hi!</title>
32 </html>
32 </html>
33 HTML
33 HTML
34
34
35 print "first,".join(',', 'second', qq~third~);
35 print "first,".join(',', 'second', qq~third~);
36
36
37 if($s1 =~ m[(?<!\s)(l.ne)\z]o) {
37 if($s1 =~ m[(?<!\s)(l.ne)\z]o) {
38 $h->{$1}=$$.' predefined variables';
38 $h->{$1}=$$.' predefined variables';
39 $s2 =~ s/\-line//ox;
39 $s2 =~ s/\-line//ox;
40 $s1 =~ s[
40 $s1 =~ s[
41 line ]
41 line ]
42 [
42 [
43 block
43 block
44 ]ox;
44 ]ox;
45 }
45 }
46
46
47 1; # numbers and comments
47 1; # numbers and comments
48
48
49 __END__
49 __END__
50 something...
50 something...
51
51
52 </textarea></div>
52 </textarea></div>
53
53
54 <script>
54 <script>
55 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
55 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
56 lineNumbers: true
56 lineNumbers: true
57 });
57 });
58 </script>
58 </script>
59
59
60 <p><strong>MIME types defined:</strong> <code>text/x-perl</code>.</p>
60 <p><strong>MIME types defined:</strong> <code>text/x-perl</code>.</p>
61 </body>
61 </body>
62 </html>
62 </html>
@@ -1,51 +1,51 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: PHP mode</title>
5 <title>CodeMirror: PHP mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="../../addon/edit/matchbrackets.js"></script>
8 <script src="../../addon/edit/matchbrackets.js"></script>
9 <script src="../htmlmixed/htmlmixed.js"></script>
9 <script src="../htmlmixed/htmlmixed.js"></script>
10 <script src="../xml/xml.js"></script>
10 <script src="../xml/xml.js"></script>
11 <script src="../javascript/javascript.js"></script>
11 <script src="../javascript/javascript.js"></script>
12 <script src="../css/css.js"></script>
12 <script src="../css/css.js"></script>
13 <script src="../clike/clike.js"></script>
13 <script src="../clike/clike.js"></script>
14 <script src="php.js"></script>
14 <script src="php.js"></script>
15 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
15 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
16 <link rel="stylesheet" href="../../doc/docs.css">
16 <link rel="stylesheet" href="../../doc/docs.css">
17 </head>
17 </head>
18 <body>
18 <body>
19 <h1>CodeMirror: PHP mode</h1>
19 <h1>CodeMirror: PHP mode</h1>
20
20
21 <form><textarea id="code" name="code">
21 <form><textarea id="code" name="code">
22 <?php
22 <?php
23 function hello($who) {
23 function hello($who) {
24 return "Hello " . $who;
24 return "Hello " . $who;
25 }
25 }
26 ?>
26 ?>
27 <p>The program says <?= hello("World") ?>.</p>
27 <p>The program says <?= hello("World") ?>.</p>
28 <script>
28 <script>
29 alert("And here is some JS code"); // also colored
29 alert("And here is some JS code"); // also colored
30 </script>
30 </script>
31 </textarea></form>
31 </textarea></form>
32
32
33 <script>
33 <script>
34 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
34 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
35 lineNumbers: true,
35 lineNumbers: true,
36 matchBrackets: true,
36 matchBrackets: true,
37 mode: "application/x-httpd-php",
37 mode: "application/x-httpd-php",
38 indentUnit: 4,
38 indentUnit: 4,
39 indentWithTabs: true,
39 indentWithTabs: true,
40 enterMode: "keep",
40 enterMode: "keep",
41 tabMode: "shift"
41 tabMode: "shift"
42 });
42 });
43 </script>
43 </script>
44
44
45 <p>Simple HTML/PHP mode based on
45 <p>Simple HTML/PHP mode based on
46 the <a href="../clike">C-like</a> mode. Depends on XML,
46 the <a href="../clike">C-like</a> mode. Depends on XML,
47 JavaScript, CSS, HTMLMixed, and C-like modes.</p>
47 JavaScript, CSS, HTMLMixed, and C-like modes.</p>
48
48
49 <p><strong>MIME types defined:</strong> <code>application/x-httpd-php</code> (HTML with PHP code), <code>text/x-php</code> (plain, non-wrapped PHP code).</p>
49 <p><strong>MIME types defined:</strong> <code>application/x-httpd-php</code> (HTML with PHP code), <code>text/x-php</code> (plain, non-wrapped PHP code).</p>
50 </body>
50 </body>
51 </html>
51 </html>
@@ -1,42 +1,42 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: Pig Latin mode</title>
5 <title>CodeMirror: Pig Latin mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="pig.js"></script>
8 <script src="pig.js"></script>
9 <link rel="stylesheet" href="../../doc/docs.css">
9 <link rel="stylesheet" href="../../doc/docs.css">
10 <style>.CodeMirror {border: 2px inset #dee;}</style>
10 <style>.CodeMirror {border: 2px inset #dee;}</style>
11 </head>
11 </head>
12 <body>
12 <body>
13 <h1>CodeMirror: Pig Latin mode</h1>
13 <h1>CodeMirror: Pig Latin mode</h1>
14
14
15 <form><textarea id="code" name="code">
15 <form><textarea id="code" name="code">
16 -- Apache Pig (Pig Latin Language) Demo
16 -- Apache Pig (Pig Latin Language) Demo
17 /*
17 /*
18 This is a multiline comment.
18 This is a multiline comment.
19 */
19 */
20 a = LOAD "\path\to\input" USING PigStorage('\t') AS (x:long, y:chararray, z:bytearray);
20 a = LOAD "\path\to\input" USING PigStorage('\t') AS (x:long, y:chararray, z:bytearray);
21 b = GROUP a BY (x,y,3+4);
21 b = GROUP a BY (x,y,3+4);
22 c = FOREACH b GENERATE flatten(group) as (x,y), SUM(group.$2) as z;
22 c = FOREACH b GENERATE flatten(group) as (x,y), SUM(group.$2) as z;
23 STORE c INTO "\path\to\output";
23 STORE c INTO "\path\to\output";
24
24
25 --
25 --
26 </textarea></form>
26 </textarea></form>
27
27
28 <script>
28 <script>
29 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
29 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
30 lineNumbers: true,
30 lineNumbers: true,
31 indentUnit: 4,
31 indentUnit: 4,
32 mode: "text/x-pig"
32 mode: "text/x-pig"
33 });
33 });
34 </script>
34 </script>
35
35
36 <p>
36 <p>
37 Simple mode that handles Pig Latin language.
37 Simple mode that handles Pig Latin language.
38 </p>
38 </p>
39
39
40 <p><strong>MIME type defined:</strong> <code>text/x-pig</code>
40 <p><strong>MIME type defined:</strong> <code>text/x-pig</code>
41 (PIG code)
41 (PIG code)
42 </html>
42 </html>
@@ -1,21 +1,21 b''
1 The MIT License
1 The MIT License
2
2
3 Copyright (c) 2010 Timothy Farrell
3 Copyright (c) 2010 Timothy Farrell
4
4
5 Permission is hereby granted, free of charge, to any person obtaining a copy
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal
6 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is
9 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions:
10 furnished to do so, subject to the following conditions:
11
11
12 The above copyright notice and this permission notice shall be included in
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
13 all copies or substantial portions of the Software.
14
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 THE SOFTWARE. No newline at end of file
21 THE SOFTWARE.
@@ -1,135 +1,135 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: Python mode</title>
5 <title>CodeMirror: Python mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="../../addon/edit/matchbrackets.js"></script>
8 <script src="../../addon/edit/matchbrackets.js"></script>
9 <script src="python.js"></script>
9 <script src="python.js"></script>
10 <link rel="stylesheet" href="../../doc/docs.css">
10 <link rel="stylesheet" href="../../doc/docs.css">
11 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
11 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
12 </head>
12 </head>
13 <body>
13 <body>
14 <h1>CodeMirror: Python mode</h1>
14 <h1>CodeMirror: Python mode</h1>
15
15
16 <div><textarea id="code" name="code">
16 <div><textarea id="code" name="code">
17 # Literals
17 # Literals
18 1234
18 1234
19 0.0e101
19 0.0e101
20 .123
20 .123
21 0b01010011100
21 0b01010011100
22 0o01234567
22 0o01234567
23 0x0987654321abcdef
23 0x0987654321abcdef
24 7
24 7
25 2147483647
25 2147483647
26 3L
26 3L
27 79228162514264337593543950336L
27 79228162514264337593543950336L
28 0x100000000L
28 0x100000000L
29 79228162514264337593543950336
29 79228162514264337593543950336
30 0xdeadbeef
30 0xdeadbeef
31 3.14j
31 3.14j
32 10.j
32 10.j
33 10j
33 10j
34 .001j
34 .001j
35 1e100j
35 1e100j
36 3.14e-10j
36 3.14e-10j
37
37
38
38
39 # String Literals
39 # String Literals
40 'For\''
40 'For\''
41 "God\""
41 "God\""
42 """so loved
42 """so loved
43 the world"""
43 the world"""
44 '''that he gave
44 '''that he gave
45 his only begotten\' '''
45 his only begotten\' '''
46 'that whosoever believeth \
46 'that whosoever believeth \
47 in him'
47 in him'
48 ''
48 ''
49
49
50 # Identifiers
50 # Identifiers
51 __a__
51 __a__
52 a.b
52 a.b
53 a.b.c
53 a.b.c
54
54
55 # Operators
55 # Operators
56 + - * / % & | ^ ~ < >
56 + - * / % & | ^ ~ < >
57 == != <= >= <> << >> // **
57 == != <= >= <> << >> // **
58 and or not in is
58 and or not in is
59
59
60 # Delimiters
60 # Delimiters
61 () [] {} , : ` = ; @ . # Note that @ and . require the proper context.
61 () [] {} , : ` = ; @ . # Note that @ and . require the proper context.
62 += -= *= /= %= &= |= ^=
62 += -= *= /= %= &= |= ^=
63 //= >>= <<= **=
63 //= >>= <<= **=
64
64
65 # Keywords
65 # Keywords
66 as assert break class continue def del elif else except
66 as assert break class continue def del elif else except
67 finally for from global if import lambda pass raise
67 finally for from global if import lambda pass raise
68 return try while with yield
68 return try while with yield
69
69
70 # Python 2 Keywords (otherwise Identifiers)
70 # Python 2 Keywords (otherwise Identifiers)
71 exec print
71 exec print
72
72
73 # Python 3 Keywords (otherwise Identifiers)
73 # Python 3 Keywords (otherwise Identifiers)
74 nonlocal
74 nonlocal
75
75
76 # Types
76 # Types
77 bool classmethod complex dict enumerate float frozenset int list object
77 bool classmethod complex dict enumerate float frozenset int list object
78 property reversed set slice staticmethod str super tuple type
78 property reversed set slice staticmethod str super tuple type
79
79
80 # Python 2 Types (otherwise Identifiers)
80 # Python 2 Types (otherwise Identifiers)
81 basestring buffer file long unicode xrange
81 basestring buffer file long unicode xrange
82
82
83 # Python 3 Types (otherwise Identifiers)
83 # Python 3 Types (otherwise Identifiers)
84 bytearray bytes filter map memoryview open range zip
84 bytearray bytes filter map memoryview open range zip
85
85
86 # Some Example code
86 # Some Example code
87 import os
87 import os
88 from package import ParentClass
88 from package import ParentClass
89
89
90 @nonsenseDecorator
90 @nonsenseDecorator
91 def doesNothing():
91 def doesNothing():
92 pass
92 pass
93
93
94 class ExampleClass(ParentClass):
94 class ExampleClass(ParentClass):
95 @staticmethod
95 @staticmethod
96 def example(inputStr):
96 def example(inputStr):
97 a = list(inputStr)
97 a = list(inputStr)
98 a.reverse()
98 a.reverse()
99 return ''.join(a)
99 return ''.join(a)
100
100
101 def __init__(self, mixin = 'Hello'):
101 def __init__(self, mixin = 'Hello'):
102 self.mixin = mixin
102 self.mixin = mixin
103
103
104 </textarea></div>
104 </textarea></div>
105 <script>
105 <script>
106 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
106 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
107 mode: {name: "python",
107 mode: {name: "python",
108 version: 2,
108 version: 2,
109 singleLineStringErrors: false},
109 singleLineStringErrors: false},
110 lineNumbers: true,
110 lineNumbers: true,
111 indentUnit: 4,
111 indentUnit: 4,
112 tabMode: "shift",
112 tabMode: "shift",
113 matchBrackets: true
113 matchBrackets: true
114 });
114 });
115 </script>
115 </script>
116 <h2>Configuration Options:</h2>
116 <h2>Configuration Options:</h2>
117 <ul>
117 <ul>
118 <li>version - 2/3 - The version of Python to recognize. Default is 2.</li>
118 <li>version - 2/3 - The version of Python to recognize. Default is 2.</li>
119 <li>singleLineStringErrors - true/false - If you have a single-line string that is not terminated at the end of the line, this will show subsequent lines as errors if true, otherwise it will consider the newline as the end of the string. Default is false.</li>
119 <li>singleLineStringErrors - true/false - If you have a single-line string that is not terminated at the end of the line, this will show subsequent lines as errors if true, otherwise it will consider the newline as the end of the string. Default is false.</li>
120 </ul>
120 </ul>
121 <h2>Advanced Configuration Options:</h2>
121 <h2>Advanced Configuration Options:</h2>
122 <p>Usefull for superset of python syntax like Enthought enaml, IPython magics and questionmark help</p>
122 <p>Usefull for superset of python syntax like Enthought enaml, IPython magics and questionmark help</p>
123 <ul>
123 <ul>
124 <li>singleOperators - RegEx - Regular Expression for single operator matching, default : <pre>^[\\+\\-\\*/%&amp;|\\^~&lt;&gt;!]</pre></li>
124 <li>singleOperators - RegEx - Regular Expression for single operator matching, default : <pre>^[\\+\\-\\*/%&amp;|\\^~&lt;&gt;!]</pre></li>
125 <li>singleDelimiters - RegEx - Regular Expression for single delimiter matching, default : <pre>^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]</pre></li>
125 <li>singleDelimiters - RegEx - Regular Expression for single delimiter matching, default : <pre>^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]</pre></li>
126 <li>doubleOperators - RegEx - Regular Expression for double operators matching, default : <pre>^((==)|(!=)|(&lt;=)|(&gt;=)|(&lt;&gt;)|(&lt;&lt;)|(&gt;&gt;)|(//)|(\\*\\*))</pre></li>
126 <li>doubleOperators - RegEx - Regular Expression for double operators matching, default : <pre>^((==)|(!=)|(&lt;=)|(&gt;=)|(&lt;&gt;)|(&lt;&lt;)|(&gt;&gt;)|(//)|(\\*\\*))</pre></li>
127 <li>doubleDelimiters - RegEx - Regular Expressoin for double delimiters matching, default : <pre>^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&amp;=)|(\\|=)|(\\^=))</pre></li>
127 <li>doubleDelimiters - RegEx - Regular Expressoin for double delimiters matching, default : <pre>^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&amp;=)|(\\|=)|(\\^=))</pre></li>
128 <li>tripleDelimiters - RegEx - Regular Expression for triple delimiters matching, default : <pre>^((//=)|(&gt;&gt;=)|(&lt;&lt;=)|(\\*\\*=))</pre></li>
128 <li>tripleDelimiters - RegEx - Regular Expression for triple delimiters matching, default : <pre>^((//=)|(&gt;&gt;=)|(&lt;&lt;=)|(\\*\\*=))</pre></li>
129 <li>identifiers - RegEx - Regular Expression for identifier, default : <pre>^[_A-Za-z][_A-Za-z0-9]*</pre></li>
129 <li>identifiers - RegEx - Regular Expression for identifier, default : <pre>^[_A-Za-z][_A-Za-z0-9]*</pre></li>
130 </ul>
130 </ul>
131
131
132
132
133 <p><strong>MIME types defined:</strong> <code>text/x-python</code>.</p>
133 <p><strong>MIME types defined:</strong> <code>text/x-python</code>.</p>
134 </body>
134 </body>
135 </html>
135 </html>
@@ -1,131 +1,131 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: Q mode</title>
5 <title>CodeMirror: Q mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="../../addon/edit/matchbrackets.js"></script>
8 <script src="../../addon/edit/matchbrackets.js"></script>
9 <script src="q.js"></script>
9 <script src="q.js"></script>
10 <link rel="stylesheet" href="../../doc/docs.css">
10 <link rel="stylesheet" href="../../doc/docs.css">
11 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
11 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
12 </head>
12 </head>
13 <body>
13 <body>
14 <h1>CodeMirror: Q mode</h1>
14 <h1>CodeMirror: Q mode</h1>
15
15
16 <div><textarea id="code" name="code">
16 <div><textarea id="code" name="code">
17 / utilities to quickly load a csv file - for more exhaustive analysis of the csv contents see csvguess.q
17 / utilities to quickly load a csv file - for more exhaustive analysis of the csv contents see csvguess.q
18 / 2009.09.20 - updated to match latest csvguess.q
18 / 2009.09.20 - updated to match latest csvguess.q
19
19
20 / .csv.colhdrs[file] - return a list of colhdrs from file
20 / .csv.colhdrs[file] - return a list of colhdrs from file
21 / info:.csv.info[file] - return a table of information about the file
21 / info:.csv.info[file] - return a table of information about the file
22 / columns are:
22 / columns are:
23 / c - column name; ci - column index; t - load type; mw - max width;
23 / c - column name; ci - column index; t - load type; mw - max width;
24 / dchar - distinct characters in values; rule - rule that caught the type
24 / dchar - distinct characters in values; rule - rule that caught the type
25 / maybe - needs checking, _could_ be say a date, but perhaps just a float?
25 / maybe - needs checking, _could_ be say a date, but perhaps just a float?
26 / .csv.info0[file;onlycols] - like .csv.info except that it only analyses <onlycols>
26 / .csv.info0[file;onlycols] - like .csv.info except that it only analyses <onlycols>
27 / example:
27 / example:
28 / info:.csv.info0[file;(.csv.colhdrs file)like"*price"]
28 / info:.csv.info0[file;(.csv.colhdrs file)like"*price"]
29 / info:.csv.infolike[file;"*price"]
29 / info:.csv.infolike[file;"*price"]
30 / show delete from info where t=" "
30 / show delete from info where t=" "
31 / .csv.data[file;info] - use the info from .csv.info to read the data
31 / .csv.data[file;info] - use the info from .csv.info to read the data
32 / .csv.data10[file;info] - like .csv.data but only returns the first 10 rows
32 / .csv.data10[file;info] - like .csv.data but only returns the first 10 rows
33 / bulkload[file;info] - bulk loads file into table DATA (which must be already defined :: DATA:() )
33 / bulkload[file;info] - bulk loads file into table DATA (which must be already defined :: DATA:() )
34 / .csv.read[file]/read10[file] - for when you don't care about checking/tweaking the <info> before reading
34 / .csv.read[file]/read10[file] - for when you don't care about checking/tweaking the <info> before reading
35
35
36 \d .csv
36 \d .csv
37 DELIM:","
37 DELIM:","
38 ZAPHDRS:0b / lowercase and remove _ from colhdrs (junk characters are always removed)
38 ZAPHDRS:0b / lowercase and remove _ from colhdrs (junk characters are always removed)
39 WIDTHHDR:25000 / number of characters read to get the header
39 WIDTHHDR:25000 / number of characters read to get the header
40 READLINES:222 / number of lines read and used to guess the types
40 READLINES:222 / number of lines read and used to guess the types
41 SYMMAXWIDTH:11 / character columns narrower than this are stored as symbols
41 SYMMAXWIDTH:11 / character columns narrower than this are stored as symbols
42 SYMMAXGR:10 / max symbol granularity% before we give up and keep as a * string
42 SYMMAXGR:10 / max symbol granularity% before we give up and keep as a * string
43 FORCECHARWIDTH:30 / every field (of any type) with values this wide or more is forced to character "*"
43 FORCECHARWIDTH:30 / every field (of any type) with values this wide or more is forced to character "*"
44 DISCARDEMPTY:0b / completely ignore empty columns if true else set them to "C"
44 DISCARDEMPTY:0b / completely ignore empty columns if true else set them to "C"
45 CHUNKSIZE:50000000 / used in fs2 (modified .Q.fs)
45 CHUNKSIZE:50000000 / used in fs2 (modified .Q.fs)
46
46
47 k)nameltrim:{$[~@x;.z.s'x;~(*x)in aA:.Q.a,.Q.A;(+/&\~x in aA)_x;x]}
47 k)nameltrim:{$[~@x;.z.s'x;~(*x)in aA:.Q.a,.Q.A;(+/&\~x in aA)_x;x]}
48 k)fs2:{[f;s]((-7!s)>){[f;s;x]i:1+last@&0xa=r:1:(s;x;CHUNKSIZE);f@`\:i#r;x+i}[f;s]/0j}
48 k)fs2:{[f;s]((-7!s)>){[f;s;x]i:1+last@&0xa=r:1:(s;x;CHUNKSIZE);f@`\:i#r;x+i}[f;s]/0j}
49 cleanhdrs:{{$[ZAPHDRS;lower x except"_";x]}x where x in DELIM,.Q.an}
49 cleanhdrs:{{$[ZAPHDRS;lower x except"_";x]}x where x in DELIM,.Q.an}
50 cancast:{nw:x$"";if[not x in"BXCS";nw:(min 0#;max 0#;::)@\:nw];$[not any nw in x$(11&count y)#y;$[11<count y;not any nw in x$y;1b];0b]}
50 cancast:{nw:x$"";if[not x in"BXCS";nw:(min 0#;max 0#;::)@\:nw];$[not any nw in x$(11&count y)#y;$[11<count y;not any nw in x$y;1b];0b]}
51
51
52 read:{[file]data[file;info[file]]}
52 read:{[file]data[file;info[file]]}
53 read10:{[file]data10[file;info[file]]}
53 read10:{[file]data10[file;info[file]]}
54
54
55 colhdrs:{[file]
55 colhdrs:{[file]
56 `$nameltrim DELIM vs cleanhdrs first read0(file;0;1+first where 0xa=read1(file;0;WIDTHHDR))}
56 `$nameltrim DELIM vs cleanhdrs first read0(file;0;1+first where 0xa=read1(file;0;WIDTHHDR))}
57 data:{[file;info]
57 data:{[file;info]
58 (exec c from info where not t=" ")xcol(exec t from info;enlist DELIM)0:file}
58 (exec c from info where not t=" ")xcol(exec t from info;enlist DELIM)0:file}
59 data10:{[file;info]
59 data10:{[file;info]
60 data[;info](file;0;1+last 11#where 0xa=read1(file;0;15*WIDTHHDR))}
60 data[;info](file;0;1+last 11#where 0xa=read1(file;0;15*WIDTHHDR))}
61 info0:{[file;onlycols]
61 info0:{[file;onlycols]
62 colhdrs:`$nameltrim DELIM vs cleanhdrs first head:read0(file;0;1+last where 0xa=read1(file;0;WIDTHHDR));
62 colhdrs:`$nameltrim DELIM vs cleanhdrs first head:read0(file;0;1+last where 0xa=read1(file;0;WIDTHHDR));
63 loadfmts:(count colhdrs)#"S";if[count onlycols;loadfmts[where not colhdrs in onlycols]:"C"];
63 loadfmts:(count colhdrs)#"S";if[count onlycols;loadfmts[where not colhdrs in onlycols]:"C"];
64 breaks:where 0xa=read1(file;0;floor(10+READLINES)*WIDTHHDR%count head);
64 breaks:where 0xa=read1(file;0;floor(10+READLINES)*WIDTHHDR%count head);
65 nas:count as:colhdrs xcol(loadfmts;enlist DELIM)0:(file;0;1+last((1+READLINES)&count breaks)#breaks);
65 nas:count as:colhdrs xcol(loadfmts;enlist DELIM)0:(file;0;1+last((1+READLINES)&count breaks)#breaks);
66 info:([]c:key flip as;v:value flip as);as:();
66 info:([]c:key flip as;v:value flip as);as:();
67 reserved:key`.q;reserved,:.Q.res;reserved,:`i;
67 reserved:key`.q;reserved,:.Q.res;reserved,:`i;
68 info:update res:c in reserved from info;
68 info:update res:c in reserved from info;
69 info:update ci:i,t:"?",ipa:0b,mdot:0,mw:0,rule:0,gr:0,ndv:0,maybe:0b,empty:0b,j10:0b,j12:0b from info;
69 info:update ci:i,t:"?",ipa:0b,mdot:0,mw:0,rule:0,gr:0,ndv:0,maybe:0b,empty:0b,j10:0b,j12:0b from info;
70 info:update ci:`s#ci from info;
70 info:update ci:`s#ci from info;
71 if[count onlycols;info:update t:" ",rule:10 from info where not c in onlycols];
71 if[count onlycols;info:update t:" ",rule:10 from info where not c in onlycols];
72 info:update sdv:{string(distinct x)except`}peach v from info;
72 info:update sdv:{string(distinct x)except`}peach v from info;
73 info:update ndv:count each sdv from info;
73 info:update ndv:count each sdv from info;
74 info:update gr:floor 0.5+100*ndv%nas,mw:{max count each x}peach sdv from info where 0<ndv;
74 info:update gr:floor 0.5+100*ndv%nas,mw:{max count each x}peach sdv from info where 0<ndv;
75 info:update t:"*",rule:20 from info where mw>.csv.FORCECHARWIDTH; / long values
75 info:update t:"*",rule:20 from info where mw>.csv.FORCECHARWIDTH; / long values
76 info:update t:"C "[.csv.DISCARDEMPTY],rule:30,empty:1b from info where t="?",mw=0; / empty columns
76 info:update t:"C "[.csv.DISCARDEMPTY],rule:30,empty:1b from info where t="?",mw=0; / empty columns
77 info:update dchar:{asc distinct raze x}peach sdv from info where t="?";
77 info:update dchar:{asc distinct raze x}peach sdv from info where t="?";
78 info:update mdot:{max sum each"."=x}peach sdv from info where t="?",{"."in x}each dchar;
78 info:update mdot:{max sum each"."=x}peach sdv from info where t="?",{"."in x}each dchar;
79 info:update t:"n",rule:40 from info where t="?",{any x in"0123456789"}each dchar; / vaguely numeric..
79 info:update t:"n",rule:40 from info where t="?",{any x in"0123456789"}each dchar; / vaguely numeric..
80 info:update t:"I",rule:50,ipa:1b from info where t="n",mw within 7 15,mdot=3,{all x in".0123456789"}each dchar,.csv.cancast["I"]peach sdv; / ip-address
80 info:update t:"I",rule:50,ipa:1b from info where t="n",mw within 7 15,mdot=3,{all x in".0123456789"}each dchar,.csv.cancast["I"]peach sdv; / ip-address
81 info:update t:"J",rule:60 from info where t="n",mdot=0,{all x in"+-0123456789"}each dchar,.csv.cancast["J"]peach sdv;
81 info:update t:"J",rule:60 from info where t="n",mdot=0,{all x in"+-0123456789"}each dchar,.csv.cancast["J"]peach sdv;
82 info:update t:"I",rule:70 from info where t="J",mw<12,.csv.cancast["I"]peach sdv;
82 info:update t:"I",rule:70 from info where t="J",mw<12,.csv.cancast["I"]peach sdv;
83 info:update t:"H",rule:80 from info where t="I",mw<7,.csv.cancast["H"]peach sdv;
83 info:update t:"H",rule:80 from info where t="I",mw<7,.csv.cancast["H"]peach sdv;
84 info:update t:"F",rule:90 from info where t="n",mdot<2,mw>1,.csv.cancast["F"]peach sdv;
84 info:update t:"F",rule:90 from info where t="n",mdot<2,mw>1,.csv.cancast["F"]peach sdv;
85 info:update t:"E",rule:100,maybe:1b from info where t="F",mw<9;
85 info:update t:"E",rule:100,maybe:1b from info where t="F",mw<9;
86 info:update t:"M",rule:110,maybe:1b from info where t in"nIHEF",mdot<2,mw within 4 7,.csv.cancast["M"]peach sdv;
86 info:update t:"M",rule:110,maybe:1b from info where t in"nIHEF",mdot<2,mw within 4 7,.csv.cancast["M"]peach sdv;
87 info:update t:"D",rule:120,maybe:1b from info where t in"nI",mdot in 0 2,mw within 6 11,.csv.cancast["D"]peach sdv;
87 info:update t:"D",rule:120,maybe:1b from info where t in"nI",mdot in 0 2,mw within 6 11,.csv.cancast["D"]peach sdv;
88 info:update t:"V",rule:130,maybe:1b from info where t="I",mw in 5 6,7<count each dchar,{all x like"*[0-9][0-5][0-9][0-5][0-9]"}peach sdv,.csv.cancast["V"]peach sdv; / 235959 12345
88 info:update t:"V",rule:130,maybe:1b from info where t="I",mw in 5 6,7<count each dchar,{all x like"*[0-9][0-5][0-9][0-5][0-9]"}peach sdv,.csv.cancast["V"]peach sdv; / 235959 12345
89 info:update t:"U",rule:140,maybe:1b from info where t="H",mw in 3 4,7<count each dchar,{all x like"*[0-9][0-5][0-9]"}peach sdv,.csv.cancast["U"]peach sdv; /2359
89 info:update t:"U",rule:140,maybe:1b from info where t="H",mw in 3 4,7<count each dchar,{all x like"*[0-9][0-5][0-9]"}peach sdv,.csv.cancast["U"]peach sdv; /2359
90 info:update t:"U",rule:150,maybe:0b from info where t="n",mw in 4 5,mdot=0,{all x like"*[0-9]:[0-5][0-9]"}peach sdv,.csv.cancast["U"]peach sdv;
90 info:update t:"U",rule:150,maybe:0b from info where t="n",mw in 4 5,mdot=0,{all x like"*[0-9]:[0-5][0-9]"}peach sdv,.csv.cancast["U"]peach sdv;
91 info:update t:"T",rule:160,maybe:0b from info where t="n",mw within 7 12,mdot<2,{all x like"*[0-9]:[0-5][0-9]:[0-5][0-9]*"}peach sdv,.csv.cancast["T"]peach sdv;
91 info:update t:"T",rule:160,maybe:0b from info where t="n",mw within 7 12,mdot<2,{all x like"*[0-9]:[0-5][0-9]:[0-5][0-9]*"}peach sdv,.csv.cancast["T"]peach sdv;
92 info:update t:"V",rule:170,maybe:0b from info where t="T",mw in 7 8,mdot=0,.csv.cancast["V"]peach sdv;
92 info:update t:"V",rule:170,maybe:0b from info where t="T",mw in 7 8,mdot=0,.csv.cancast["V"]peach sdv;
93 info:update t:"T",rule:180,maybe:1b from info where t in"EF",mw within 7 10,mdot=1,{all x like"*[0-9][0-5][0-9][0-5][0-9].*"}peach sdv,.csv.cancast["T"]peach sdv;
93 info:update t:"T",rule:180,maybe:1b from info where t in"EF",mw within 7 10,mdot=1,{all x like"*[0-9][0-5][0-9][0-5][0-9].*"}peach sdv,.csv.cancast["T"]peach sdv;
94 info:update t:"Z",rule:190,maybe:0b from info where t="n",mw within 11 24,mdot<4,.csv.cancast["Z"]peach sdv;
94 info:update t:"Z",rule:190,maybe:0b from info where t="n",mw within 11 24,mdot<4,.csv.cancast["Z"]peach sdv;
95 info:update t:"P",rule:200,maybe:1b from info where t="n",mw within 12 29,mdot<4,{all x like"[12]*"}peach sdv,.csv.cancast["P"]peach sdv;
95 info:update t:"P",rule:200,maybe:1b from info where t="n",mw within 12 29,mdot<4,{all x like"[12]*"}peach sdv,.csv.cancast["P"]peach sdv;
96 info:update t:"N",rule:210,maybe:1b from info where t="n",mw within 3 28,mdot=1,.csv.cancast["N"]peach sdv;
96 info:update t:"N",rule:210,maybe:1b from info where t="n",mw within 3 28,mdot=1,.csv.cancast["N"]peach sdv;
97 info:update t:"?",rule:220,maybe:0b from info where t="n"; / reset remaining maybe numeric
97 info:update t:"?",rule:220,maybe:0b from info where t="n"; / reset remaining maybe numeric
98 info:update t:"C",rule:230,maybe:0b from info where t="?",mw=1; / char
98 info:update t:"C",rule:230,maybe:0b from info where t="?",mw=1; / char
99 info:update t:"B",rule:240,maybe:0b from info where t in"HC",mw=1,mdot=0,{$[all x in"01tTfFyYnN";(any"0fFnN"in x)and any"1tTyY"in x;0b]}each dchar; / boolean
99 info:update t:"B",rule:240,maybe:0b from info where t in"HC",mw=1,mdot=0,{$[all x in"01tTfFyYnN";(any"0fFnN"in x)and any"1tTyY"in x;0b]}each dchar; / boolean
100 info:update t:"B",rule:250,maybe:1b from info where t in"HC",mw=1,mdot=0,{all x in"01tTfFyYnN"}each dchar; / boolean
100 info:update t:"B",rule:250,maybe:1b from info where t in"HC",mw=1,mdot=0,{all x in"01tTfFyYnN"}each dchar; / boolean
101 info:update t:"X",rule:260,maybe:0b from info where t="?",mw=2,{$[all x in"0123456789abcdefABCDEF";(any .Q.n in x)and any"abcdefABCDEF"in x;0b]}each dchar; /hex
101 info:update t:"X",rule:260,maybe:0b from info where t="?",mw=2,{$[all x in"0123456789abcdefABCDEF";(any .Q.n in x)and any"abcdefABCDEF"in x;0b]}each dchar; /hex
102 info:update t:"S",rule:270,maybe:1b from info where t="?",mw<.csv.SYMMAXWIDTH,mw>1,gr<.csv.SYMMAXGR; / symbols (max width permitting)
102 info:update t:"S",rule:270,maybe:1b from info where t="?",mw<.csv.SYMMAXWIDTH,mw>1,gr<.csv.SYMMAXGR; / symbols (max width permitting)
103 info:update t:"*",rule:280,maybe:0b from info where t="?"; / the rest as strings
103 info:update t:"*",rule:280,maybe:0b from info where t="?"; / the rest as strings
104 / flag those S/* columns which could be encoded to integers (.Q.j10/x10/j12/x12) to avoid symbols
104 / flag those S/* columns which could be encoded to integers (.Q.j10/x10/j12/x12) to avoid symbols
105 info:update j12:1b from info where t in"S*",mw<13,{all x in .Q.nA}each dchar;
105 info:update j12:1b from info where t in"S*",mw<13,{all x in .Q.nA}each dchar;
106 info:update j10:1b from info where t in"S*",mw<11,{all x in .Q.b6}each dchar;
106 info:update j10:1b from info where t in"S*",mw<11,{all x in .Q.b6}each dchar;
107 select c,ci,t,maybe,empty,res,j10,j12,ipa,mw,mdot,rule,gr,ndv,dchar from info}
107 select c,ci,t,maybe,empty,res,j10,j12,ipa,mw,mdot,rule,gr,ndv,dchar from info}
108 info:info0[;()] / by default don't restrict columns
108 info:info0[;()] / by default don't restrict columns
109 infolike:{[file;pattern] info0[file;{x where x like y}[lower colhdrs[file];pattern]]} / .csv.infolike[file;"*time"]
109 infolike:{[file;pattern] info0[file;{x where x like y}[lower colhdrs[file];pattern]]} / .csv.infolike[file;"*time"]
110
110
111 \d .
111 \d .
112 / DATA:()
112 / DATA:()
113 bulkload:{[file;info]
113 bulkload:{[file;info]
114 if[not`DATA in system"v";'`DATA.not.defined];
114 if[not`DATA in system"v";'`DATA.not.defined];
115 if[count DATA;'`DATA.not.empty];
115 if[count DATA;'`DATA.not.empty];
116 loadhdrs:exec c from info where not t=" ";loadfmts:exec t from info;
116 loadhdrs:exec c from info where not t=" ";loadfmts:exec t from info;
117 .csv.fs2[{[file;loadhdrs;loadfmts] `DATA insert $[count DATA;flip loadhdrs!(loadfmts;.csv.DELIM)0:file;loadhdrs xcol(loadfmts;enlist .csv.DELIM)0:file]}[file;loadhdrs;loadfmts]];
117 .csv.fs2[{[file;loadhdrs;loadfmts] `DATA insert $[count DATA;flip loadhdrs!(loadfmts;.csv.DELIM)0:file;loadhdrs xcol(loadfmts;enlist .csv.DELIM)0:file]}[file;loadhdrs;loadfmts]];
118 count DATA}
118 count DATA}
119 @[.:;"\\l csvutil.custom.q";::]; / save your custom settings in csvutil.custom.q to override those set at the beginning of the file
119 @[.:;"\\l csvutil.custom.q";::]; / save your custom settings in csvutil.custom.q to override those set at the beginning of the file
120 </textarea></div>
120 </textarea></div>
121
121
122 <script>
122 <script>
123 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
123 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
124 lineNumbers: true,
124 lineNumbers: true,
125 matchBrackets: true
125 matchBrackets: true
126 });
126 });
127 </script>
127 </script>
128
128
129 <p><strong>MIME type defined:</strong> <code>text/x-q</code>.</p>
129 <p><strong>MIME type defined:</strong> <code>text/x-q</code>.</p>
130 </body>
130 </body>
131 </html>
131 </html>
@@ -1,53 +1,53 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: RPM changes mode</title>
5 <title>CodeMirror: RPM changes mode</title>
6 <link rel="stylesheet" href="../../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../../lib/codemirror.css">
7 <script src="../../../lib/codemirror.js"></script>
7 <script src="../../../lib/codemirror.js"></script>
8 <script src="changes.js"></script>
8 <script src="changes.js"></script>
9 <link rel="stylesheet" href="../../../doc/docs.css">
9 <link rel="stylesheet" href="../../../doc/docs.css">
10 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
10 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
11 </head>
11 </head>
12 <body>
12 <body>
13 <h1>CodeMirror: RPM changes mode</h1>
13 <h1>CodeMirror: RPM changes mode</h1>
14
14
15 <div><textarea id="code" name="code">
15 <div><textarea id="code" name="code">
16 -------------------------------------------------------------------
16 -------------------------------------------------------------------
17 Tue Oct 18 13:58:40 UTC 2011 - misterx@example.com
17 Tue Oct 18 13:58:40 UTC 2011 - misterx@example.com
18
18
19 - Update to r60.3
19 - Update to r60.3
20 - Fixes bug in the reflect package
20 - Fixes bug in the reflect package
21 * disallow Interface method on Value obtained via unexported name
21 * disallow Interface method on Value obtained via unexported name
22
22
23 -------------------------------------------------------------------
23 -------------------------------------------------------------------
24 Thu Oct 6 08:14:24 UTC 2011 - misterx@example.com
24 Thu Oct 6 08:14:24 UTC 2011 - misterx@example.com
25
25
26 - Update to r60.2
26 - Update to r60.2
27 - Fixes memory leak in certain map types
27 - Fixes memory leak in certain map types
28
28
29 -------------------------------------------------------------------
29 -------------------------------------------------------------------
30 Wed Oct 5 14:34:10 UTC 2011 - misterx@example.com
30 Wed Oct 5 14:34:10 UTC 2011 - misterx@example.com
31
31
32 - Tweaks for gdb debugging
32 - Tweaks for gdb debugging
33 - go.spec changes:
33 - go.spec changes:
34 - move %go_arch definition to %prep section
34 - move %go_arch definition to %prep section
35 - pass correct location of go specific gdb pretty printer and
35 - pass correct location of go specific gdb pretty printer and
36 functions to cpp as HOST_EXTRA_CFLAGS macro
36 functions to cpp as HOST_EXTRA_CFLAGS macro
37 - install go gdb functions & printer
37 - install go gdb functions & printer
38 - gdb-printer.patch
38 - gdb-printer.patch
39 - patch linker (src/cmd/ld/dwarf.c) to emit correct location of go
39 - patch linker (src/cmd/ld/dwarf.c) to emit correct location of go
40 gdb functions and pretty printer
40 gdb functions and pretty printer
41 </textarea></div>
41 </textarea></div>
42 <script>
42 <script>
43 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
43 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
44 mode: {name: "changes"},
44 mode: {name: "changes"},
45 lineNumbers: true,
45 lineNumbers: true,
46 indentUnit: 4,
46 indentUnit: 4,
47 tabMode: "shift"
47 tabMode: "shift"
48 });
48 });
49 </script>
49 </script>
50
50
51 <p><strong>MIME types defined:</strong> <code>text/x-rpm-changes</code>.</p>
51 <p><strong>MIME types defined:</strong> <code>text/x-rpm-changes</code>.</p>
52 </body>
52 </body>
53 </html>
53 </html>
@@ -1,99 +1,99 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: RPM spec mode</title>
5 <title>CodeMirror: RPM spec mode</title>
6 <link rel="stylesheet" href="../../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../../lib/codemirror.css">
7 <script src="../../../lib/codemirror.js"></script>
7 <script src="../../../lib/codemirror.js"></script>
8 <script src="spec.js"></script>
8 <script src="spec.js"></script>
9 <link rel="stylesheet" href="spec.css">
9 <link rel="stylesheet" href="spec.css">
10 <link rel="stylesheet" href="../../../doc/docs.css">
10 <link rel="stylesheet" href="../../../doc/docs.css">
11 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
11 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
12 </head>
12 </head>
13 <body>
13 <body>
14 <h1>CodeMirror: RPM spec mode</h1>
14 <h1>CodeMirror: RPM spec mode</h1>
15
15
16 <div><textarea id="code" name="code">
16 <div><textarea id="code" name="code">
17 #
17 #
18 # spec file for package minidlna
18 # spec file for package minidlna
19 #
19 #
20 # Copyright (c) 2011, Sascha Peilicke <saschpe@gmx.de>
20 # Copyright (c) 2011, Sascha Peilicke <saschpe@gmx.de>
21 #
21 #
22 # All modifications and additions to the file contributed by third parties
22 # All modifications and additions to the file contributed by third parties
23 # remain the property of their copyright owners, unless otherwise agreed
23 # remain the property of their copyright owners, unless otherwise agreed
24 # upon. The license for this file, and modifications and additions to the
24 # upon. The license for this file, and modifications and additions to the
25 # file, is the same license as for the pristine package itself (unless the
25 # file, is the same license as for the pristine package itself (unless the
26 # license for the pristine package is not an Open Source License, in which
26 # license for the pristine package is not an Open Source License, in which
27 # case the license is the MIT License). An "Open Source License" is a
27 # case the license is the MIT License). An "Open Source License" is a
28 # license that conforms to the Open Source Definition (Version 1.9)
28 # license that conforms to the Open Source Definition (Version 1.9)
29 # published by the Open Source Initiative.
29 # published by the Open Source Initiative.
30
30
31
31
32 Name: libupnp6
32 Name: libupnp6
33 Version: 1.6.13
33 Version: 1.6.13
34 Release: 0
34 Release: 0
35 Summary: Portable Universal Plug and Play (UPnP) SDK
35 Summary: Portable Universal Plug and Play (UPnP) SDK
36 Group: System/Libraries
36 Group: System/Libraries
37 License: BSD-3-Clause
37 License: BSD-3-Clause
38 Url: http://sourceforge.net/projects/pupnp/
38 Url: http://sourceforge.net/projects/pupnp/
39 Source0: http://downloads.sourceforge.net/pupnp/libupnp-%{version}.tar.bz2
39 Source0: http://downloads.sourceforge.net/pupnp/libupnp-%{version}.tar.bz2
40 BuildRoot: %{_tmppath}/%{name}-%{version}-build
40 BuildRoot: %{_tmppath}/%{name}-%{version}-build
41
41
42 %description
42 %description
43 The portable Universal Plug and Play (UPnP) SDK provides support for building
43 The portable Universal Plug and Play (UPnP) SDK provides support for building
44 UPnP-compliant control points, devices, and bridges on several operating
44 UPnP-compliant control points, devices, and bridges on several operating
45 systems.
45 systems.
46
46
47 %package -n libupnp-devel
47 %package -n libupnp-devel
48 Summary: Portable Universal Plug and Play (UPnP) SDK
48 Summary: Portable Universal Plug and Play (UPnP) SDK
49 Group: Development/Libraries/C and C++
49 Group: Development/Libraries/C and C++
50 Provides: pkgconfig(libupnp)
50 Provides: pkgconfig(libupnp)
51 Requires: %{name} = %{version}
51 Requires: %{name} = %{version}
52
52
53 %description -n libupnp-devel
53 %description -n libupnp-devel
54 The portable Universal Plug and Play (UPnP) SDK provides support for building
54 The portable Universal Plug and Play (UPnP) SDK provides support for building
55 UPnP-compliant control points, devices, and bridges on several operating
55 UPnP-compliant control points, devices, and bridges on several operating
56 systems.
56 systems.
57
57
58 %prep
58 %prep
59 %setup -n libupnp-%{version}
59 %setup -n libupnp-%{version}
60
60
61 %build
61 %build
62 %configure --disable-static
62 %configure --disable-static
63 make %{?_smp_mflags}
63 make %{?_smp_mflags}
64
64
65 %install
65 %install
66 %makeinstall
66 %makeinstall
67 find %{buildroot} -type f -name '*.la' -exec rm -f {} ';'
67 find %{buildroot} -type f -name '*.la' -exec rm -f {} ';'
68
68
69 %post -p /sbin/ldconfig
69 %post -p /sbin/ldconfig
70
70
71 %postun -p /sbin/ldconfig
71 %postun -p /sbin/ldconfig
72
72
73 %files
73 %files
74 %defattr(-,root,root,-)
74 %defattr(-,root,root,-)
75 %doc ChangeLog NEWS README TODO
75 %doc ChangeLog NEWS README TODO
76 %{_libdir}/libixml.so.*
76 %{_libdir}/libixml.so.*
77 %{_libdir}/libthreadutil.so.*
77 %{_libdir}/libthreadutil.so.*
78 %{_libdir}/libupnp.so.*
78 %{_libdir}/libupnp.so.*
79
79
80 %files -n libupnp-devel
80 %files -n libupnp-devel
81 %defattr(-,root,root,-)
81 %defattr(-,root,root,-)
82 %{_libdir}/pkgconfig/libupnp.pc
82 %{_libdir}/pkgconfig/libupnp.pc
83 %{_libdir}/libixml.so
83 %{_libdir}/libixml.so
84 %{_libdir}/libthreadutil.so
84 %{_libdir}/libthreadutil.so
85 %{_libdir}/libupnp.so
85 %{_libdir}/libupnp.so
86 %{_includedir}/upnp/
86 %{_includedir}/upnp/
87
87
88 %changelog</textarea></div>
88 %changelog</textarea></div>
89 <script>
89 <script>
90 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
90 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
91 mode: {name: "spec"},
91 mode: {name: "spec"},
92 lineNumbers: true,
92 lineNumbers: true,
93 indentUnit: 4
93 indentUnit: 4
94 });
94 });
95 </script>
95 </script>
96
96
97 <p><strong>MIME types defined:</strong> <code>text/x-rpm-spec</code>.</p>
97 <p><strong>MIME types defined:</strong> <code>text/x-rpm-spec</code>.</p>
98 </body>
98 </body>
99 </html>
99 </html>
@@ -1,21 +1,21 b''
1 The MIT License
1 The MIT License
2
2
3 Copyright (c) 2013 Hasan Karahan
3 Copyright (c) 2013 Hasan Karahan
4
4
5 Permission is hereby granted, free of charge, to any person obtaining a copy
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal
6 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is
9 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions:
10 furnished to do so, subject to the following conditions:
11
11
12 The above copyright notice and this permission notice shall be included in
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
13 all copies or substantial portions of the Software.
14
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 THE SOFTWARE. No newline at end of file
21 THE SOFTWARE.
@@ -1,524 +1,523 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: reStructuredText mode</title>
5 <title>CodeMirror: reStructuredText mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="rst.js"></script>
8 <script src="rst.js"></script>
9 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
9 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
10 <link rel="stylesheet" href="../../doc/docs.css">
10 <link rel="stylesheet" href="../../doc/docs.css">
11 </head>
11 </head>
12 <body>
12 <body>
13 <h1>CodeMirror: reStructuredText mode</h1>
13 <h1>CodeMirror: reStructuredText mode</h1>
14
14
15 <form><textarea id="code" name="code">
15 <form><textarea id="code" name="code">
16 .. This is an excerpt from Sphinx documentation: http://sphinx.pocoo.org/_sources/rest.txt
16 .. This is an excerpt from Sphinx documentation: http://sphinx.pocoo.org/_sources/rest.txt
17
17
18 .. highlightlang:: rest
18 .. highlightlang:: rest
19
19
20 .. _rst-primer:
20 .. _rst-primer:
21
21
22 reStructuredText Primer
22 reStructuredText Primer
23 =======================
23 =======================
24
24
25 This section is a brief introduction to reStructuredText (reST) concepts and
25 This section is a brief introduction to reStructuredText (reST) concepts and
26 syntax, intended to provide authors with enough information to author documents
26 syntax, intended to provide authors with enough information to author documents
27 productively. Since reST was designed to be a simple, unobtrusive markup
27 productively. Since reST was designed to be a simple, unobtrusive markup
28 language, this will not take too long.
28 language, this will not take too long.
29
29
30 .. seealso::
30 .. seealso::
31
31
32 The authoritative `reStructuredText User Documentation
32 The authoritative `reStructuredText User Documentation
33 &lt;http://docutils.sourceforge.net/rst.html&gt;`_. The "ref" links in this
33 &lt;http://docutils.sourceforge.net/rst.html&gt;`_. The "ref" links in this
34 document link to the description of the individual constructs in the reST
34 document link to the description of the individual constructs in the reST
35 reference.
35 reference.
36
36
37
37
38 Paragraphs
38 Paragraphs
39 ----------
39 ----------
40
40
41 The paragraph (:duref:`ref &lt;paragraphs&gt;`) is the most basic block in a reST
41 The paragraph (:duref:`ref &lt;paragraphs&gt;`) is the most basic block in a reST
42 document. Paragraphs are simply chunks of text separated by one or more blank
42 document. Paragraphs are simply chunks of text separated by one or more blank
43 lines. As in Python, indentation is significant in reST, so all lines of the
43 lines. As in Python, indentation is significant in reST, so all lines of the
44 same paragraph must be left-aligned to the same level of indentation.
44 same paragraph must be left-aligned to the same level of indentation.
45
45
46
46
47 .. _inlinemarkup:
47 .. _inlinemarkup:
48
48
49 Inline markup
49 Inline markup
50 -------------
50 -------------
51
51
52 The standard reST inline markup is quite simple: use
52 The standard reST inline markup is quite simple: use
53
53
54 * one asterisk: ``*text*`` for emphasis (italics),
54 * one asterisk: ``*text*`` for emphasis (italics),
55 * two asterisks: ``**text**`` for strong emphasis (boldface), and
55 * two asterisks: ``**text**`` for strong emphasis (boldface), and
56 * backquotes: ````text```` for code samples.
56 * backquotes: ````text```` for code samples.
57
57
58 If asterisks or backquotes appear in running text and could be confused with
58 If asterisks or backquotes appear in running text and could be confused with
59 inline markup delimiters, they have to be escaped with a backslash.
59 inline markup delimiters, they have to be escaped with a backslash.
60
60
61 Be aware of some restrictions of this markup:
61 Be aware of some restrictions of this markup:
62
62
63 * it may not be nested,
63 * it may not be nested,
64 * content may not start or end with whitespace: ``* text*`` is wrong,
64 * content may not start or end with whitespace: ``* text*`` is wrong,
65 * it must be separated from surrounding text by non-word characters. Use a
65 * it must be separated from surrounding text by non-word characters. Use a
66 backslash escaped space to work around that: ``thisis\ *one*\ word``.
66 backslash escaped space to work around that: ``thisis\ *one*\ word``.
67
67
68 These restrictions may be lifted in future versions of the docutils.
68 These restrictions may be lifted in future versions of the docutils.
69
69
70 reST also allows for custom "interpreted text roles"', which signify that the
70 reST also allows for custom "interpreted text roles"', which signify that the
71 enclosed text should be interpreted in a specific way. Sphinx uses this to
71 enclosed text should be interpreted in a specific way. Sphinx uses this to
72 provide semantic markup and cross-referencing of identifiers, as described in
72 provide semantic markup and cross-referencing of identifiers, as described in
73 the appropriate section. The general syntax is ``:rolename:`content```.
73 the appropriate section. The general syntax is ``:rolename:`content```.
74
74
75 Standard reST provides the following roles:
75 Standard reST provides the following roles:
76
76
77 * :durole:`emphasis` -- alternate spelling for ``*emphasis*``
77 * :durole:`emphasis` -- alternate spelling for ``*emphasis*``
78 * :durole:`strong` -- alternate spelling for ``**strong**``
78 * :durole:`strong` -- alternate spelling for ``**strong**``
79 * :durole:`literal` -- alternate spelling for ````literal````
79 * :durole:`literal` -- alternate spelling for ````literal````
80 * :durole:`subscript` -- subscript text
80 * :durole:`subscript` -- subscript text
81 * :durole:`superscript` -- superscript text
81 * :durole:`superscript` -- superscript text
82 * :durole:`title-reference` -- for titles of books, periodicals, and other
82 * :durole:`title-reference` -- for titles of books, periodicals, and other
83 materials
83 materials
84
84
85 See :ref:`inline-markup` for roles added by Sphinx.
85 See :ref:`inline-markup` for roles added by Sphinx.
86
86
87
87
88 Lists and Quote-like blocks
88 Lists and Quote-like blocks
89 ---------------------------
89 ---------------------------
90
90
91 List markup (:duref:`ref &lt;bullet-lists&gt;`) is natural: just place an asterisk at
91 List markup (:duref:`ref &lt;bullet-lists&gt;`) is natural: just place an asterisk at
92 the start of a paragraph and indent properly. The same goes for numbered lists;
92 the start of a paragraph and indent properly. The same goes for numbered lists;
93 they can also be autonumbered using a ``#`` sign::
93 they can also be autonumbered using a ``#`` sign::
94
94
95 * This is a bulleted list.
95 * This is a bulleted list.
96 * It has two items, the second
96 * It has two items, the second
97 item uses two lines.
97 item uses two lines.
98
98
99 1. This is a numbered list.
99 1. This is a numbered list.
100 2. It has two items too.
100 2. It has two items too.
101
101
102 #. This is a numbered list.
102 #. This is a numbered list.
103 #. It has two items too.
103 #. It has two items too.
104
104
105
105
106 Nested lists are possible, but be aware that they must be separated from the
106 Nested lists are possible, but be aware that they must be separated from the
107 parent list items by blank lines::
107 parent list items by blank lines::
108
108
109 * this is
109 * this is
110 * a list
110 * a list
111
111
112 * with a nested list
112 * with a nested list
113 * and some subitems
113 * and some subitems
114
114
115 * and here the parent list continues
115 * and here the parent list continues
116
116
117 Definition lists (:duref:`ref &lt;definition-lists&gt;`) are created as follows::
117 Definition lists (:duref:`ref &lt;definition-lists&gt;`) are created as follows::
118
118
119 term (up to a line of text)
119 term (up to a line of text)
120 Definition of the term, which must be indented
120 Definition of the term, which must be indented
121
121
122 and can even consist of multiple paragraphs
122 and can even consist of multiple paragraphs
123
123
124 next term
124 next term
125 Description.
125 Description.
126
126
127 Note that the term cannot have more than one line of text.
127 Note that the term cannot have more than one line of text.
128
128
129 Quoted paragraphs (:duref:`ref &lt;block-quotes&gt;`) are created by just indenting
129 Quoted paragraphs (:duref:`ref &lt;block-quotes&gt;`) are created by just indenting
130 them more than the surrounding paragraphs.
130 them more than the surrounding paragraphs.
131
131
132 Line blocks (:duref:`ref &lt;line-blocks&gt;`) are a way of preserving line breaks::
132 Line blocks (:duref:`ref &lt;line-blocks&gt;`) are a way of preserving line breaks::
133
133
134 | These lines are
134 | These lines are
135 | broken exactly like in
135 | broken exactly like in
136 | the source file.
136 | the source file.
137
137
138 There are also several more special blocks available:
138 There are also several more special blocks available:
139
139
140 * field lists (:duref:`ref &lt;field-lists&gt;`)
140 * field lists (:duref:`ref &lt;field-lists&gt;`)
141 * option lists (:duref:`ref &lt;option-lists&gt;`)
141 * option lists (:duref:`ref &lt;option-lists&gt;`)
142 * quoted literal blocks (:duref:`ref &lt;quoted-literal-blocks&gt;`)
142 * quoted literal blocks (:duref:`ref &lt;quoted-literal-blocks&gt;`)
143 * doctest blocks (:duref:`ref &lt;doctest-blocks&gt;`)
143 * doctest blocks (:duref:`ref &lt;doctest-blocks&gt;`)
144
144
145
145
146 Source Code
146 Source Code
147 -----------
147 -----------
148
148
149 Literal code blocks (:duref:`ref &lt;literal-blocks&gt;`) are introduced by ending a
149 Literal code blocks (:duref:`ref &lt;literal-blocks&gt;`) are introduced by ending a
150 paragraph with the special marker ``::``. The literal block must be indented
150 paragraph with the special marker ``::``. The literal block must be indented
151 (and, like all paragraphs, separated from the surrounding ones by blank lines)::
151 (and, like all paragraphs, separated from the surrounding ones by blank lines)::
152
152
153 This is a normal text paragraph. The next paragraph is a code sample::
153 This is a normal text paragraph. The next paragraph is a code sample::
154
154
155 It is not processed in any way, except
155 It is not processed in any way, except
156 that the indentation is removed.
156 that the indentation is removed.
157
157
158 It can span multiple lines.
158 It can span multiple lines.
159
159
160 This is a normal text paragraph again.
160 This is a normal text paragraph again.
161
161
162 The handling of the ``::`` marker is smart:
162 The handling of the ``::`` marker is smart:
163
163
164 * If it occurs as a paragraph of its own, that paragraph is completely left
164 * If it occurs as a paragraph of its own, that paragraph is completely left
165 out of the document.
165 out of the document.
166 * If it is preceded by whitespace, the marker is removed.
166 * If it is preceded by whitespace, the marker is removed.
167 * If it is preceded by non-whitespace, the marker is replaced by a single
167 * If it is preceded by non-whitespace, the marker is replaced by a single
168 colon.
168 colon.
169
169
170 That way, the second sentence in the above example's first paragraph would be
170 That way, the second sentence in the above example's first paragraph would be
171 rendered as "The next paragraph is a code sample:".
171 rendered as "The next paragraph is a code sample:".
172
172
173
173
174 .. _rst-tables:
174 .. _rst-tables:
175
175
176 Tables
176 Tables
177 ------
177 ------
178
178
179 Two forms of tables are supported. For *grid tables* (:duref:`ref
179 Two forms of tables are supported. For *grid tables* (:duref:`ref
180 &lt;grid-tables&gt;`), you have to "paint" the cell grid yourself. They look like
180 &lt;grid-tables&gt;`), you have to "paint" the cell grid yourself. They look like
181 this::
181 this::
182
182
183 +------------------------+------------+----------+----------+
183 +------------------------+------------+----------+----------+
184 | Header row, column 1 | Header 2 | Header 3 | Header 4 |
184 | Header row, column 1 | Header 2 | Header 3 | Header 4 |
185 | (header rows optional) | | | |
185 | (header rows optional) | | | |
186 +========================+============+==========+==========+
186 +========================+============+==========+==========+
187 | body row 1, column 1 | column 2 | column 3 | column 4 |
187 | body row 1, column 1 | column 2 | column 3 | column 4 |
188 +------------------------+------------+----------+----------+
188 +------------------------+------------+----------+----------+
189 | body row 2 | ... | ... | |
189 | body row 2 | ... | ... | |
190 +------------------------+------------+----------+----------+
190 +------------------------+------------+----------+----------+
191
191
192 *Simple tables* (:duref:`ref &lt;simple-tables&gt;`) are easier to write, but
192 *Simple tables* (:duref:`ref &lt;simple-tables&gt;`) are easier to write, but
193 limited: they must contain more than one row, and the first column cannot
193 limited: they must contain more than one row, and the first column cannot
194 contain multiple lines. They look like this::
194 contain multiple lines. They look like this::
195
195
196 ===== ===== =======
196 ===== ===== =======
197 A B A and B
197 A B A and B
198 ===== ===== =======
198 ===== ===== =======
199 False False False
199 False False False
200 True False False
200 True False False
201 False True False
201 False True False
202 True True True
202 True True True
203 ===== ===== =======
203 ===== ===== =======
204
204
205
205
206 Hyperlinks
206 Hyperlinks
207 ----------
207 ----------
208
208
209 External links
209 External links
210 ^^^^^^^^^^^^^^
210 ^^^^^^^^^^^^^^
211
211
212 Use ```Link text &lt;http://example.com/&gt;`_`` for inline web links. If the link
212 Use ```Link text &lt;http://example.com/&gt;`_`` for inline web links. If the link
213 text should be the web address, you don't need special markup at all, the parser
213 text should be the web address, you don't need special markup at all, the parser
214 finds links and mail addresses in ordinary text.
214 finds links and mail addresses in ordinary text.
215
215
216 You can also separate the link and the target definition (:duref:`ref
216 You can also separate the link and the target definition (:duref:`ref
217 &lt;hyperlink-targets&gt;`), like this::
217 &lt;hyperlink-targets&gt;`), like this::
218
218
219 This is a paragraph that contains `a link`_.
219 This is a paragraph that contains `a link`_.
220
220
221 .. _a link: http://example.com/
221 .. _a link: http://example.com/
222
222
223
223
224 Internal links
224 Internal links
225 ^^^^^^^^^^^^^^
225 ^^^^^^^^^^^^^^
226
226
227 Internal linking is done via a special reST role provided by Sphinx, see the
227 Internal linking is done via a special reST role provided by Sphinx, see the
228 section on specific markup, :ref:`ref-role`.
228 section on specific markup, :ref:`ref-role`.
229
229
230
230
231 Sections
231 Sections
232 --------
232 --------
233
233
234 Section headers (:duref:`ref &lt;sections&gt;`) are created by underlining (and
234 Section headers (:duref:`ref &lt;sections&gt;`) are created by underlining (and
235 optionally overlining) the section title with a punctuation character, at least
235 optionally overlining) the section title with a punctuation character, at least
236 as long as the text::
236 as long as the text::
237
237
238 =================
238 =================
239 This is a heading
239 This is a heading
240 =================
240 =================
241
241
242 Normally, there are no heading levels assigned to certain characters as the
242 Normally, there are no heading levels assigned to certain characters as the
243 structure is determined from the succession of headings. However, for the
243 structure is determined from the succession of headings. However, for the
244 Python documentation, this convention is used which you may follow:
244 Python documentation, this convention is used which you may follow:
245
245
246 * ``#`` with overline, for parts
246 * ``#`` with overline, for parts
247 * ``*`` with overline, for chapters
247 * ``*`` with overline, for chapters
248 * ``=``, for sections
248 * ``=``, for sections
249 * ``-``, for subsections
249 * ``-``, for subsections
250 * ``^``, for subsubsections
250 * ``^``, for subsubsections
251 * ``"``, for paragraphs
251 * ``"``, for paragraphs
252
252
253 Of course, you are free to use your own marker characters (see the reST
253 Of course, you are free to use your own marker characters (see the reST
254 documentation), and use a deeper nesting level, but keep in mind that most
254 documentation), and use a deeper nesting level, but keep in mind that most
255 target formats (HTML, LaTeX) have a limited supported nesting depth.
255 target formats (HTML, LaTeX) have a limited supported nesting depth.
256
256
257
257
258 Explicit Markup
258 Explicit Markup
259 ---------------
259 ---------------
260
260
261 "Explicit markup" (:duref:`ref &lt;explicit-markup-blocks&gt;`) is used in reST for
261 "Explicit markup" (:duref:`ref &lt;explicit-markup-blocks&gt;`) is used in reST for
262 most constructs that need special handling, such as footnotes,
262 most constructs that need special handling, such as footnotes,
263 specially-highlighted paragraphs, comments, and generic directives.
263 specially-highlighted paragraphs, comments, and generic directives.
264
264
265 An explicit markup block begins with a line starting with ``..`` followed by
265 An explicit markup block begins with a line starting with ``..`` followed by
266 whitespace and is terminated by the next paragraph at the same level of
266 whitespace and is terminated by the next paragraph at the same level of
267 indentation. (There needs to be a blank line between explicit markup and normal
267 indentation. (There needs to be a blank line between explicit markup and normal
268 paragraphs. This may all sound a bit complicated, but it is intuitive enough
268 paragraphs. This may all sound a bit complicated, but it is intuitive enough
269 when you write it.)
269 when you write it.)
270
270
271
271
272 .. _directives:
272 .. _directives:
273
273
274 Directives
274 Directives
275 ----------
275 ----------
276
276
277 A directive (:duref:`ref &lt;directives&gt;`) is a generic block of explicit markup.
277 A directive (:duref:`ref &lt;directives&gt;`) is a generic block of explicit markup.
278 Besides roles, it is one of the extension mechanisms of reST, and Sphinx makes
278 Besides roles, it is one of the extension mechanisms of reST, and Sphinx makes
279 heavy use of it.
279 heavy use of it.
280
280
281 Docutils supports the following directives:
281 Docutils supports the following directives:
282
282
283 * Admonitions: :dudir:`attention`, :dudir:`caution`, :dudir:`danger`,
283 * Admonitions: :dudir:`attention`, :dudir:`caution`, :dudir:`danger`,
284 :dudir:`error`, :dudir:`hint`, :dudir:`important`, :dudir:`note`,
284 :dudir:`error`, :dudir:`hint`, :dudir:`important`, :dudir:`note`,
285 :dudir:`tip`, :dudir:`warning` and the generic :dudir:`admonition`.
285 :dudir:`tip`, :dudir:`warning` and the generic :dudir:`admonition`.
286 (Most themes style only "note" and "warning" specially.)
286 (Most themes style only "note" and "warning" specially.)
287
287
288 * Images:
288 * Images:
289
289
290 - :dudir:`image` (see also Images_ below)
290 - :dudir:`image` (see also Images_ below)
291 - :dudir:`figure` (an image with caption and optional legend)
291 - :dudir:`figure` (an image with caption and optional legend)
292
292
293 * Additional body elements:
293 * Additional body elements:
294
294
295 - :dudir:`contents` (a local, i.e. for the current file only, table of
295 - :dudir:`contents` (a local, i.e. for the current file only, table of
296 contents)
296 contents)
297 - :dudir:`container` (a container with a custom class, useful to generate an
297 - :dudir:`container` (a container with a custom class, useful to generate an
298 outer ``&lt;div&gt;`` in HTML)
298 outer ``&lt;div&gt;`` in HTML)
299 - :dudir:`rubric` (a heading without relation to the document sectioning)
299 - :dudir:`rubric` (a heading without relation to the document sectioning)
300 - :dudir:`topic`, :dudir:`sidebar` (special highlighted body elements)
300 - :dudir:`topic`, :dudir:`sidebar` (special highlighted body elements)
301 - :dudir:`parsed-literal` (literal block that supports inline markup)
301 - :dudir:`parsed-literal` (literal block that supports inline markup)
302 - :dudir:`epigraph` (a block quote with optional attribution line)
302 - :dudir:`epigraph` (a block quote with optional attribution line)
303 - :dudir:`highlights`, :dudir:`pull-quote` (block quotes with their own
303 - :dudir:`highlights`, :dudir:`pull-quote` (block quotes with their own
304 class attribute)
304 class attribute)
305 - :dudir:`compound` (a compound paragraph)
305 - :dudir:`compound` (a compound paragraph)
306
306
307 * Special tables:
307 * Special tables:
308
308
309 - :dudir:`table` (a table with title)
309 - :dudir:`table` (a table with title)
310 - :dudir:`csv-table` (a table generated from comma-separated values)
310 - :dudir:`csv-table` (a table generated from comma-separated values)
311 - :dudir:`list-table` (a table generated from a list of lists)
311 - :dudir:`list-table` (a table generated from a list of lists)
312
312
313 * Special directives:
313 * Special directives:
314
314
315 - :dudir:`raw` (include raw target-format markup)
315 - :dudir:`raw` (include raw target-format markup)
316 - :dudir:`include` (include reStructuredText from another file)
316 - :dudir:`include` (include reStructuredText from another file)
317 -- in Sphinx, when given an absolute include file path, this directive takes
317 -- in Sphinx, when given an absolute include file path, this directive takes
318 it as relative to the source directory
318 it as relative to the source directory
319 - :dudir:`class` (assign a class attribute to the next element) [1]_
319 - :dudir:`class` (assign a class attribute to the next element) [1]_
320
320
321 * HTML specifics:
321 * HTML specifics:
322
322
323 - :dudir:`meta` (generation of HTML ``&lt;meta&gt;`` tags)
323 - :dudir:`meta` (generation of HTML ``&lt;meta&gt;`` tags)
324 - :dudir:`title` (override document title)
324 - :dudir:`title` (override document title)
325
325
326 * Influencing markup:
326 * Influencing markup:
327
327
328 - :dudir:`default-role` (set a new default role)
328 - :dudir:`default-role` (set a new default role)
329 - :dudir:`role` (create a new role)
329 - :dudir:`role` (create a new role)
330
330
331 Since these are only per-file, better use Sphinx' facilities for setting the
331 Since these are only per-file, better use Sphinx' facilities for setting the
332 :confval:`default_role`.
332 :confval:`default_role`.
333
333
334 Do *not* use the directives :dudir:`sectnum`, :dudir:`header` and
334 Do *not* use the directives :dudir:`sectnum`, :dudir:`header` and
335 :dudir:`footer`.
335 :dudir:`footer`.
336
336
337 Directives added by Sphinx are described in :ref:`sphinxmarkup`.
337 Directives added by Sphinx are described in :ref:`sphinxmarkup`.
338
338
339 Basically, a directive consists of a name, arguments, options and content. (Keep
339 Basically, a directive consists of a name, arguments, options and content. (Keep
340 this terminology in mind, it is used in the next chapter describing custom
340 this terminology in mind, it is used in the next chapter describing custom
341 directives.) Looking at this example, ::
341 directives.) Looking at this example, ::
342
342
343 .. function:: foo(x)
343 .. function:: foo(x)
344 foo(y, z)
344 foo(y, z)
345 :module: some.module.name
345 :module: some.module.name
346
346
347 Return a line of text input from the user.
347 Return a line of text input from the user.
348
348
349 ``function`` is the directive name. It is given two arguments here, the
349 ``function`` is the directive name. It is given two arguments here, the
350 remainder of the first line and the second line, as well as one option
350 remainder of the first line and the second line, as well as one option
351 ``module`` (as you can see, options are given in the lines immediately following
351 ``module`` (as you can see, options are given in the lines immediately following
352 the arguments and indicated by the colons). Options must be indented to the
352 the arguments and indicated by the colons). Options must be indented to the
353 same level as the directive content.
353 same level as the directive content.
354
354
355 The directive content follows after a blank line and is indented relative to the
355 The directive content follows after a blank line and is indented relative to the
356 directive start.
356 directive start.
357
357
358
358
359 Images
359 Images
360 ------
360 ------
361
361
362 reST supports an image directive (:dudir:`ref &lt;image&gt;`), used like so::
362 reST supports an image directive (:dudir:`ref &lt;image&gt;`), used like so::
363
363
364 .. image:: gnu.png
364 .. image:: gnu.png
365 (options)
365 (options)
366
366
367 When used within Sphinx, the file name given (here ``gnu.png``) must either be
367 When used within Sphinx, the file name given (here ``gnu.png``) must either be
368 relative to the source file, or absolute which means that they are relative to
368 relative to the source file, or absolute which means that they are relative to
369 the top source directory. For example, the file ``sketch/spam.rst`` could refer
369 the top source directory. For example, the file ``sketch/spam.rst`` could refer
370 to the image ``images/spam.png`` as ``../images/spam.png`` or
370 to the image ``images/spam.png`` as ``../images/spam.png`` or
371 ``/images/spam.png``.
371 ``/images/spam.png``.
372
372
373 Sphinx will automatically copy image files over to a subdirectory of the output
373 Sphinx will automatically copy image files over to a subdirectory of the output
374 directory on building (e.g. the ``_static`` directory for HTML output.)
374 directory on building (e.g. the ``_static`` directory for HTML output.)
375
375
376 Interpretation of image size options (``width`` and ``height``) is as follows:
376 Interpretation of image size options (``width`` and ``height``) is as follows:
377 if the size has no unit or the unit is pixels, the given size will only be
377 if the size has no unit or the unit is pixels, the given size will only be
378 respected for output channels that support pixels (i.e. not in LaTeX output).
378 respected for output channels that support pixels (i.e. not in LaTeX output).
379 Other units (like ``pt`` for points) will be used for HTML and LaTeX output.
379 Other units (like ``pt`` for points) will be used for HTML and LaTeX output.
380
380
381 Sphinx extends the standard docutils behavior by allowing an asterisk for the
381 Sphinx extends the standard docutils behavior by allowing an asterisk for the
382 extension::
382 extension::
383
383
384 .. image:: gnu.*
384 .. image:: gnu.*
385
385
386 Sphinx then searches for all images matching the provided pattern and determines
386 Sphinx then searches for all images matching the provided pattern and determines
387 their type. Each builder then chooses the best image out of these candidates.
387 their type. Each builder then chooses the best image out of these candidates.
388 For instance, if the file name ``gnu.*`` was given and two files :file:`gnu.pdf`
388 For instance, if the file name ``gnu.*`` was given and two files :file:`gnu.pdf`
389 and :file:`gnu.png` existed in the source tree, the LaTeX builder would choose
389 and :file:`gnu.png` existed in the source tree, the LaTeX builder would choose
390 the former, while the HTML builder would prefer the latter.
390 the former, while the HTML builder would prefer the latter.
391
391
392 .. versionchanged:: 0.4
392 .. versionchanged:: 0.4
393 Added the support for file names ending in an asterisk.
393 Added the support for file names ending in an asterisk.
394
394
395 .. versionchanged:: 0.6
395 .. versionchanged:: 0.6
396 Image paths can now be absolute.
396 Image paths can now be absolute.
397
397
398
398
399 Footnotes
399 Footnotes
400 ---------
400 ---------
401
401
402 For footnotes (:duref:`ref &lt;footnotes&gt;`), use ``[#name]_`` to mark the footnote
402 For footnotes (:duref:`ref &lt;footnotes&gt;`), use ``[#name]_`` to mark the footnote
403 location, and add the footnote body at the bottom of the document after a
403 location, and add the footnote body at the bottom of the document after a
404 "Footnotes" rubric heading, like so::
404 "Footnotes" rubric heading, like so::
405
405
406 Lorem ipsum [#f1]_ dolor sit amet ... [#f2]_
406 Lorem ipsum [#f1]_ dolor sit amet ... [#f2]_
407
407
408 .. rubric:: Footnotes
408 .. rubric:: Footnotes
409
409
410 .. [#f1] Text of the first footnote.
410 .. [#f1] Text of the first footnote.
411 .. [#f2] Text of the second footnote.
411 .. [#f2] Text of the second footnote.
412
412
413 You can also explicitly number the footnotes (``[1]_``) or use auto-numbered
413 You can also explicitly number the footnotes (``[1]_``) or use auto-numbered
414 footnotes without names (``[#]_``).
414 footnotes without names (``[#]_``).
415
415
416
416
417 Citations
417 Citations
418 ---------
418 ---------
419
419
420 Standard reST citations (:duref:`ref &lt;citations&gt;`) are supported, with the
420 Standard reST citations (:duref:`ref &lt;citations&gt;`) are supported, with the
421 additional feature that they are "global", i.e. all citations can be referenced
421 additional feature that they are "global", i.e. all citations can be referenced
422 from all files. Use them like so::
422 from all files. Use them like so::
423
423
424 Lorem ipsum [Ref]_ dolor sit amet.
424 Lorem ipsum [Ref]_ dolor sit amet.
425
425
426 .. [Ref] Book or article reference, URL or whatever.
426 .. [Ref] Book or article reference, URL or whatever.
427
427
428 Citation usage is similar to footnote usage, but with a label that is not
428 Citation usage is similar to footnote usage, but with a label that is not
429 numeric or begins with ``#``.
429 numeric or begins with ``#``.
430
430
431
431
432 Substitutions
432 Substitutions
433 -------------
433 -------------
434
434
435 reST supports "substitutions" (:duref:`ref &lt;substitution-definitions&gt;`), which
435 reST supports "substitutions" (:duref:`ref &lt;substitution-definitions&gt;`), which
436 are pieces of text and/or markup referred to in the text by ``|name|``. They
436 are pieces of text and/or markup referred to in the text by ``|name|``. They
437 are defined like footnotes with explicit markup blocks, like this::
437 are defined like footnotes with explicit markup blocks, like this::
438
438
439 .. |name| replace:: replacement *text*
439 .. |name| replace:: replacement *text*
440
440
441 or this::
441 or this::
442
442
443 .. |caution| image:: warning.png
443 .. |caution| image:: warning.png
444 :alt: Warning!
444 :alt: Warning!
445
445
446 See the :duref:`reST reference for substitutions &lt;substitution-definitions&gt;`
446 See the :duref:`reST reference for substitutions &lt;substitution-definitions&gt;`
447 for details.
447 for details.
448
448
449 If you want to use some substitutions for all documents, put them into
449 If you want to use some substitutions for all documents, put them into
450 :confval:`rst_prolog` or put them into a separate file and include it into all
450 :confval:`rst_prolog` or put them into a separate file and include it into all
451 documents you want to use them in, using the :rst:dir:`include` directive. (Be
451 documents you want to use them in, using the :rst:dir:`include` directive. (Be
452 sure to give the include file a file name extension differing from that of other
452 sure to give the include file a file name extension differing from that of other
453 source files, to avoid Sphinx finding it as a standalone document.)
453 source files, to avoid Sphinx finding it as a standalone document.)
454
454
455 Sphinx defines some default substitutions, see :ref:`default-substitutions`.
455 Sphinx defines some default substitutions, see :ref:`default-substitutions`.
456
456
457
457
458 Comments
458 Comments
459 --------
459 --------
460
460
461 Every explicit markup block which isn't a valid markup construct (like the
461 Every explicit markup block which isn't a valid markup construct (like the
462 footnotes above) is regarded as a comment (:duref:`ref &lt;comments&gt;`). For
462 footnotes above) is regarded as a comment (:duref:`ref &lt;comments&gt;`). For
463 example::
463 example::
464
464
465 .. This is a comment.
465 .. This is a comment.
466
466
467 You can indent text after a comment start to form multiline comments::
467 You can indent text after a comment start to form multiline comments::
468
468
469 ..
469 ..
470 This whole indented block
470 This whole indented block
471 is a comment.
471 is a comment.
472
472
473 Still in the comment.
473 Still in the comment.
474
474
475
475
476 Source encoding
476 Source encoding
477 ---------------
477 ---------------
478
478
479 Since the easiest way to include special characters like em dashes or copyright
479 Since the easiest way to include special characters like em dashes or copyright
480 signs in reST is to directly write them as Unicode characters, one has to
480 signs in reST is to directly write them as Unicode characters, one has to
481 specify an encoding. Sphinx assumes source files to be encoded in UTF-8 by
481 specify an encoding. Sphinx assumes source files to be encoded in UTF-8 by
482 default; you can change this with the :confval:`source_encoding` config value.
482 default; you can change this with the :confval:`source_encoding` config value.
483
483
484
484
485 Gotchas
485 Gotchas
486 -------
486 -------
487
487
488 There are some problems one commonly runs into while authoring reST documents:
488 There are some problems one commonly runs into while authoring reST documents:
489
489
490 * **Separation of inline markup:** As said above, inline markup spans must be
490 * **Separation of inline markup:** As said above, inline markup spans must be
491 separated from the surrounding text by non-word characters, you have to use a
491 separated from the surrounding text by non-word characters, you have to use a
492 backslash-escaped space to get around that. See `the reference
492 backslash-escaped space to get around that. See `the reference
493 &lt;http://docutils.sf.net/docs/ref/rst/restructuredtext.html#inline-markup&gt;`_
493 &lt;http://docutils.sf.net/docs/ref/rst/restructuredtext.html#inline-markup&gt;`_
494 for the details.
494 for the details.
495
495
496 * **No nested inline markup:** Something like ``*see :func:`foo`*`` is not
496 * **No nested inline markup:** Something like ``*see :func:`foo`*`` is not
497 possible.
497 possible.
498
498
499
499
500 .. rubric:: Footnotes
500 .. rubric:: Footnotes
501
501
502 .. [1] When the default domain contains a :rst:dir:`class` directive, this directive
502 .. [1] When the default domain contains a :rst:dir:`class` directive, this directive
503 will be shadowed. Therefore, Sphinx re-exports it as :rst:dir:`rst-class`.
503 will be shadowed. Therefore, Sphinx re-exports it as :rst:dir:`rst-class`.
504 </textarea></form>
504 </textarea></form>
505
505
506 <script>
506 <script>
507 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
507 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
508 lineNumbers: true,
508 lineNumbers: true,
509 });
509 });
510 </script>
510 </script>
511 <p>
511 <p>
512 The <code>python</code> mode will be used for highlighting blocks
512 The <code>python</code> mode will be used for highlighting blocks
513 containing Python/IPython terminal sessions: blocks starting with
513 containing Python/IPython terminal sessions: blocks starting with
514 <code>&gt;&gt;&gt;</code> (for Python) or <code>In [num]:</code> (for
514 <code>&gt;&gt;&gt;</code> (for Python) or <code>In [num]:</code> (for
515 IPython).
515 IPython).
516
516
517 Further, the <code>stex</code> mode will be used for highlighting
517 Further, the <code>stex</code> mode will be used for highlighting
518 blocks containing LaTex code.
518 blocks containing LaTex code.
519 </p>
519 </p>
520
520
521 <p><strong>MIME types defined:</strong> <code>text/x-rst</code>.</p>
521 <p><strong>MIME types defined:</strong> <code>text/x-rst</code>.</p>
522 </body>
522 </body>
523 </html>
523 </html>
524
@@ -1,173 +1,173 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: Ruby mode</title>
5 <title>CodeMirror: Ruby mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="../../addon/edit/matchbrackets.js"></script>
8 <script src="../../addon/edit/matchbrackets.js"></script>
9 <script src="ruby.js"></script>
9 <script src="ruby.js"></script>
10 <style>
10 <style>
11 .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
11 .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
12 .cm-s-default span.cm-arrow { color: red; }
12 .cm-s-default span.cm-arrow { color: red; }
13 </style>
13 </style>
14 <link rel="stylesheet" href="../../doc/docs.css">
14 <link rel="stylesheet" href="../../doc/docs.css">
15 </head>
15 </head>
16 <body>
16 <body>
17 <h1>CodeMirror: Ruby mode</h1>
17 <h1>CodeMirror: Ruby mode</h1>
18 <form><textarea id="code" name="code">
18 <form><textarea id="code" name="code">
19 # Code from http://sandbox.mc.edu/~bennet/ruby/code/poly_rb.html
19 # Code from http://sandbox.mc.edu/~bennet/ruby/code/poly_rb.html
20 #
20 #
21 # This program evaluates polynomials. It first asks for the coefficients
21 # This program evaluates polynomials. It first asks for the coefficients
22 # of a polynomial, which must be entered on one line, highest-order first.
22 # of a polynomial, which must be entered on one line, highest-order first.
23 # It then requests values of x and will compute the value of the poly for
23 # It then requests values of x and will compute the value of the poly for
24 # each x. It will repeatly ask for x values, unless you the user enters
24 # each x. It will repeatly ask for x values, unless you the user enters
25 # a blank line. It that case, it will ask for another polynomial. If the
25 # a blank line. It that case, it will ask for another polynomial. If the
26 # user types quit for either input, the program immediately exits.
26 # user types quit for either input, the program immediately exits.
27 #
27 #
28
28
29 #
29 #
30 # Function to evaluate a polynomial at x. The polynomial is given
30 # Function to evaluate a polynomial at x. The polynomial is given
31 # as a list of coefficients, from the greatest to the least.
31 # as a list of coefficients, from the greatest to the least.
32 def polyval(x, coef)
32 def polyval(x, coef)
33 sum = 0
33 sum = 0
34 coef = coef.clone # Don't want to destroy the original
34 coef = coef.clone # Don't want to destroy the original
35 while true
35 while true
36 sum += coef.shift # Add and remove the next coef
36 sum += coef.shift # Add and remove the next coef
37 break if coef.empty? # If no more, done entirely.
37 break if coef.empty? # If no more, done entirely.
38 sum *= x # This happens the right number of times.
38 sum *= x # This happens the right number of times.
39 end
39 end
40 return sum
40 return sum
41 end
41 end
42
42
43 #
43 #
44 # Function to read a line containing a list of integers and return
44 # Function to read a line containing a list of integers and return
45 # them as an array of integers. If the string conversion fails, it
45 # them as an array of integers. If the string conversion fails, it
46 # throws TypeError. If the input line is the word 'quit', then it
46 # throws TypeError. If the input line is the word 'quit', then it
47 # converts it to an end-of-file exception
47 # converts it to an end-of-file exception
48 def readints(prompt)
48 def readints(prompt)
49 # Read a line
49 # Read a line
50 print prompt
50 print prompt
51 line = readline.chomp
51 line = readline.chomp
52 raise EOFError.new if line == 'quit' # You can also use a real EOF.
52 raise EOFError.new if line == 'quit' # You can also use a real EOF.
53
53
54 # Go through each item on the line, converting each one and adding it
54 # Go through each item on the line, converting each one and adding it
55 # to retval.
55 # to retval.
56 retval = [ ]
56 retval = [ ]
57 for str in line.split(/\s+/)
57 for str in line.split(/\s+/)
58 if str =~ /^\-?\d+$/
58 if str =~ /^\-?\d+$/
59 retval.push(str.to_i)
59 retval.push(str.to_i)
60 else
60 else
61 raise TypeError.new
61 raise TypeError.new
62 end
62 end
63 end
63 end
64
64
65 return retval
65 return retval
66 end
66 end
67
67
68 #
68 #
69 # Take a coeff and an exponent and return the string representation, ignoring
69 # Take a coeff and an exponent and return the string representation, ignoring
70 # the sign of the coefficient.
70 # the sign of the coefficient.
71 def term_to_str(coef, exp)
71 def term_to_str(coef, exp)
72 ret = ""
72 ret = ""
73
73
74 # Show coeff, unless it's 1 or at the right
74 # Show coeff, unless it's 1 or at the right
75 coef = coef.abs
75 coef = coef.abs
76 ret = coef.to_s unless coef == 1 && exp > 0
76 ret = coef.to_s unless coef == 1 && exp > 0
77 ret += "x" if exp > 0 # x if exponent not 0
77 ret += "x" if exp > 0 # x if exponent not 0
78 ret += "^" + exp.to_s if exp > 1 # ^exponent, if > 1.
78 ret += "^" + exp.to_s if exp > 1 # ^exponent, if > 1.
79
79
80 return ret
80 return ret
81 end
81 end
82
82
83 #
83 #
84 # Create a string of the polynomial in sort-of-readable form.
84 # Create a string of the polynomial in sort-of-readable form.
85 def polystr(p)
85 def polystr(p)
86 # Get the exponent of first coefficient, plus 1.
86 # Get the exponent of first coefficient, plus 1.
87 exp = p.length
87 exp = p.length
88
88
89 # Assign exponents to each term, making pairs of coeff and exponent,
89 # Assign exponents to each term, making pairs of coeff and exponent,
90 # Then get rid of the zero terms.
90 # Then get rid of the zero terms.
91 p = (p.map { |c| exp -= 1; [ c, exp ] }).select { |p| p[0] != 0 }
91 p = (p.map { |c| exp -= 1; [ c, exp ] }).select { |p| p[0] != 0 }
92
92
93 # If there's nothing left, it's a zero
93 # If there's nothing left, it's a zero
94 return "0" if p.empty?
94 return "0" if p.empty?
95
95
96 # *** Now p is a non-empty list of [ coef, exponent ] pairs. ***
96 # *** Now p is a non-empty list of [ coef, exponent ] pairs. ***
97
97
98 # Convert the first term, preceded by a "-" if it's negative.
98 # Convert the first term, preceded by a "-" if it's negative.
99 result = (if p[0][0] < 0 then "-" else "" end) + term_to_str(*p[0])
99 result = (if p[0][0] < 0 then "-" else "" end) + term_to_str(*p[0])
100
100
101 # Convert the rest of the terms, in each case adding the appropriate
101 # Convert the rest of the terms, in each case adding the appropriate
102 # + or - separating them.
102 # + or - separating them.
103 for term in p[1...p.length]
103 for term in p[1...p.length]
104 # Add the separator then the rep. of the term.
104 # Add the separator then the rep. of the term.
105 result += (if term[0] < 0 then " - " else " + " end) +
105 result += (if term[0] < 0 then " - " else " + " end) +
106 term_to_str(*term)
106 term_to_str(*term)
107 end
107 end
108
108
109 return result
109 return result
110 end
110 end
111
111
112 #
112 #
113 # Run until some kind of endfile.
113 # Run until some kind of endfile.
114 begin
114 begin
115 # Repeat until an exception or quit gets us out.
115 # Repeat until an exception or quit gets us out.
116 while true
116 while true
117 # Read a poly until it works. An EOF will except out of the
117 # Read a poly until it works. An EOF will except out of the
118 # program.
118 # program.
119 print "\n"
119 print "\n"
120 begin
120 begin
121 poly = readints("Enter a polynomial coefficients: ")
121 poly = readints("Enter a polynomial coefficients: ")
122 rescue TypeError
122 rescue TypeError
123 print "Try again.\n"
123 print "Try again.\n"
124 retry
124 retry
125 end
125 end
126 break if poly.empty?
126 break if poly.empty?
127
127
128 # Read and evaluate x values until the user types a blank line.
128 # Read and evaluate x values until the user types a blank line.
129 # Again, an EOF will except out of the pgm.
129 # Again, an EOF will except out of the pgm.
130 while true
130 while true
131 # Request an integer.
131 # Request an integer.
132 print "Enter x value or blank line: "
132 print "Enter x value or blank line: "
133 x = readline.chomp
133 x = readline.chomp
134 break if x == ''
134 break if x == ''
135 raise EOFError.new if x == 'quit'
135 raise EOFError.new if x == 'quit'
136
136
137 # If it looks bad, let's try again.
137 # If it looks bad, let's try again.
138 if x !~ /^\-?\d+$/
138 if x !~ /^\-?\d+$/
139 print "That doesn't look like an integer. Please try again.\n"
139 print "That doesn't look like an integer. Please try again.\n"
140 next
140 next
141 end
141 end
142
142
143 # Convert to an integer and print the result.
143 # Convert to an integer and print the result.
144 x = x.to_i
144 x = x.to_i
145 print "p(x) = ", polystr(poly), "\n"
145 print "p(x) = ", polystr(poly), "\n"
146 print "p(", x, ") = ", polyval(x, poly), "\n"
146 print "p(", x, ") = ", polyval(x, poly), "\n"
147 end
147 end
148 end
148 end
149 rescue EOFError
149 rescue EOFError
150 print "\n=== EOF ===\n"
150 print "\n=== EOF ===\n"
151 rescue Interrupt, SignalException
151 rescue Interrupt, SignalException
152 print "\n=== Interrupted ===\n"
152 print "\n=== Interrupted ===\n"
153 else
153 else
154 print "--- Bye ---\n"
154 print "--- Bye ---\n"
155 end
155 end
156 </textarea></form>
156 </textarea></form>
157 <script>
157 <script>
158 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
158 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
159 mode: "text/x-ruby",
159 mode: "text/x-ruby",
160 tabMode: "indent",
160 tabMode: "indent",
161 matchBrackets: true,
161 matchBrackets: true,
162 indentUnit: 4
162 indentUnit: 4
163 });
163 });
164 </script>
164 </script>
165
165
166 <p><strong>MIME types defined:</strong> <code>text/x-ruby</code>.</p>
166 <p><strong>MIME types defined:</strong> <code>text/x-ruby</code>.</p>
167
167
168 <p>Development of the CodeMirror Ruby mode was kindly sponsored
168 <p>Development of the CodeMirror Ruby mode was kindly sponsored
169 by <a href="http://ubalo.com/">Ubalo</a>, who hold
169 by <a href="http://ubalo.com/">Ubalo</a>, who hold
170 the <a href="LICENSE">license</a>.</p>
170 the <a href="LICENSE">license</a>.</p>
171
171
172 </body>
172 </body>
173 </html>
173 </html>
@@ -1,65 +1,65 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: Scheme mode</title>
5 <title>CodeMirror: Scheme mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="scheme.js"></script>
8 <script src="scheme.js"></script>
9 <style>.CodeMirror {background: #f8f8f8;}</style>
9 <style>.CodeMirror {background: #f8f8f8;}</style>
10 <link rel="stylesheet" href="../../doc/docs.css">
10 <link rel="stylesheet" href="../../doc/docs.css">
11 </head>
11 </head>
12 <body>
12 <body>
13 <h1>CodeMirror: Scheme mode</h1>
13 <h1>CodeMirror: Scheme mode</h1>
14 <form><textarea id="code" name="code">
14 <form><textarea id="code" name="code">
15 ; See if the input starts with a given symbol.
15 ; See if the input starts with a given symbol.
16 (define (match-symbol input pattern)
16 (define (match-symbol input pattern)
17 (cond ((null? (remain input)) #f)
17 (cond ((null? (remain input)) #f)
18 ((eqv? (car (remain input)) pattern) (r-cdr input))
18 ((eqv? (car (remain input)) pattern) (r-cdr input))
19 (else #f)))
19 (else #f)))
20
20
21 ; Allow the input to start with one of a list of patterns.
21 ; Allow the input to start with one of a list of patterns.
22 (define (match-or input pattern)
22 (define (match-or input pattern)
23 (cond ((null? pattern) #f)
23 (cond ((null? pattern) #f)
24 ((match-pattern input (car pattern)))
24 ((match-pattern input (car pattern)))
25 (else (match-or input (cdr pattern)))))
25 (else (match-or input (cdr pattern)))))
26
26
27 ; Allow a sequence of patterns.
27 ; Allow a sequence of patterns.
28 (define (match-seq input pattern)
28 (define (match-seq input pattern)
29 (if (null? pattern)
29 (if (null? pattern)
30 input
30 input
31 (let ((match (match-pattern input (car pattern))))
31 (let ((match (match-pattern input (car pattern))))
32 (if match (match-seq match (cdr pattern)) #f))))
32 (if match (match-seq match (cdr pattern)) #f))))
33
33
34 ; Match with the pattern but no problem if it does not match.
34 ; Match with the pattern but no problem if it does not match.
35 (define (match-opt input pattern)
35 (define (match-opt input pattern)
36 (let ((match (match-pattern input (car pattern))))
36 (let ((match (match-pattern input (car pattern))))
37 (if match match input)))
37 (if match match input)))
38
38
39 ; Match anything (other than '()), until pattern is found. The rather
39 ; Match anything (other than '()), until pattern is found. The rather
40 ; clumsy form of requiring an ending pattern is needed to decide where
40 ; clumsy form of requiring an ending pattern is needed to decide where
41 ; the end of the match is. If none is given, this will match the rest
41 ; the end of the match is. If none is given, this will match the rest
42 ; of the sentence.
42 ; of the sentence.
43 (define (match-any input pattern)
43 (define (match-any input pattern)
44 (cond ((null? (remain input)) #f)
44 (cond ((null? (remain input)) #f)
45 ((null? pattern) (f-cons (remain input) (clear-remain input)))
45 ((null? pattern) (f-cons (remain input) (clear-remain input)))
46 (else
46 (else
47 (let ((accum-any (collector)))
47 (let ((accum-any (collector)))
48 (define (match-pattern-any input pattern)
48 (define (match-pattern-any input pattern)
49 (cond ((null? (remain input)) #f)
49 (cond ((null? (remain input)) #f)
50 (else (accum-any (car (remain input)))
50 (else (accum-any (car (remain input)))
51 (cond ((match-pattern (r-cdr input) pattern))
51 (cond ((match-pattern (r-cdr input) pattern))
52 (else (match-pattern-any (r-cdr input) pattern))))))
52 (else (match-pattern-any (r-cdr input) pattern))))))
53 (let ((retval (match-pattern-any input (car pattern))))
53 (let ((retval (match-pattern-any input (car pattern))))
54 (if retval
54 (if retval
55 (f-cons (accum-any) retval)
55 (f-cons (accum-any) retval)
56 #f))))))
56 #f))))))
57 </textarea></form>
57 </textarea></form>
58 <script>
58 <script>
59 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
59 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
60 </script>
60 </script>
61
61
62 <p><strong>MIME types defined:</strong> <code>text/x-scheme</code>.</p>
62 <p><strong>MIME types defined:</strong> <code>text/x-scheme</code>.</p>
63
63
64 </body>
64 </body>
65 </html>
65 </html>
@@ -1,57 +1,57 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: Smalltalk mode</title>
5 <title>CodeMirror: Smalltalk mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="../../addon/edit/matchbrackets.js"></script>
8 <script src="../../addon/edit/matchbrackets.js"></script>
9 <script src="smalltalk.js"></script>
9 <script src="smalltalk.js"></script>
10 <link rel="stylesheet" href="../../doc/docs.css">
10 <link rel="stylesheet" href="../../doc/docs.css">
11 <style>
11 <style>
12 .CodeMirror {border: 2px solid #dee; border-right-width: 10px;}
12 .CodeMirror {border: 2px solid #dee; border-right-width: 10px;}
13 .CodeMirror-gutter {border: none; background: #dee;}
13 .CodeMirror-gutter {border: none; background: #dee;}
14 .CodeMirror-gutter pre {color: white; font-weight: bold;}
14 .CodeMirror-gutter pre {color: white; font-weight: bold;}
15 </style>
15 </style>
16 </head>
16 </head>
17 <body>
17 <body>
18 <h1>CodeMirror: Smalltalk mode</h1>
18 <h1>CodeMirror: Smalltalk mode</h1>
19
19
20 <form><textarea id="code" name="code">
20 <form><textarea id="code" name="code">
21 "
21 "
22 This is a test of the Smalltalk code
22 This is a test of the Smalltalk code
23 "
23 "
24 Seaside.WAComponent subclass: #MyCounter [
24 Seaside.WAComponent subclass: #MyCounter [
25 | count |
25 | count |
26 MyCounter class &gt;&gt; canBeRoot [ ^true ]
26 MyCounter class &gt;&gt; canBeRoot [ ^true ]
27
27
28 initialize [
28 initialize [
29 super initialize.
29 super initialize.
30 count := 0.
30 count := 0.
31 ]
31 ]
32 states [ ^{ self } ]
32 states [ ^{ self } ]
33 renderContentOn: html [
33 renderContentOn: html [
34 html heading: count.
34 html heading: count.
35 html anchor callback: [ count := count + 1 ]; with: '++'.
35 html anchor callback: [ count := count + 1 ]; with: '++'.
36 html space.
36 html space.
37 html anchor callback: [ count := count - 1 ]; with: '--'.
37 html anchor callback: [ count := count - 1 ]; with: '--'.
38 ]
38 ]
39 ]
39 ]
40
40
41 MyCounter registerAsApplication: 'mycounter'
41 MyCounter registerAsApplication: 'mycounter'
42 </textarea></form>
42 </textarea></form>
43
43
44 <script>
44 <script>
45 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
45 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
46 lineNumbers: true,
46 lineNumbers: true,
47 matchBrackets: true,
47 matchBrackets: true,
48 mode: "text/x-stsrc",
48 mode: "text/x-stsrc",
49 indentUnit: 4
49 indentUnit: 4
50 });
50 });
51 </script>
51 </script>
52
52
53 <p>Simple Smalltalk mode.</p>
53 <p>Simple Smalltalk mode.</p>
54
54
55 <p><strong>MIME types defined:</strong> <code>text/x-stsrc</code>.</p>
55 <p><strong>MIME types defined:</strong> <code>text/x-stsrc</code>.</p>
56 </body>
56 </body>
57 </html>
57 </html>
@@ -1,126 +1,126 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: Smarty mode</title>
5 <title>CodeMirror: Smarty mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="smarty.js"></script>
8 <script src="smarty.js"></script>
9 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
9 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
10 <link rel="stylesheet" href="../../doc/docs.css">
10 <link rel="stylesheet" href="../../doc/docs.css">
11 </head>
11 </head>
12 <body>
12 <body>
13 <h1>CodeMirror: Smarty mode</h1>
13 <h1>CodeMirror: Smarty mode</h1>
14
14
15 <h3>Default settings (Smarty 2, <b>{</b> and <b>}</b> delimiters)</h3>
15 <h3>Default settings (Smarty 2, <b>{</b> and <b>}</b> delimiters)</h3>
16 <form><textarea id="code" name="code">
16 <form><textarea id="code" name="code">
17 {extends file="parent.tpl"}
17 {extends file="parent.tpl"}
18 {include file="template.tpl"}
18 {include file="template.tpl"}
19
19
20 {* some example Smarty content *}
20 {* some example Smarty content *}
21 {if isset($name) && $name == 'Blog'}
21 {if isset($name) && $name == 'Blog'}
22 This is a {$var}.
22 This is a {$var}.
23 {$integer = 451}, {$array[] = "a"}, {$stringvar = "string"}
23 {$integer = 451}, {$array[] = "a"}, {$stringvar = "string"}
24 {assign var='bob' value=$var.prop}
24 {assign var='bob' value=$var.prop}
25 {elseif $name == $foo}
25 {elseif $name == $foo}
26 {function name=menu level=0}
26 {function name=menu level=0}
27 {foreach $data as $entry}
27 {foreach $data as $entry}
28 {if is_array($entry)}
28 {if is_array($entry)}
29 - {$entry@key}
29 - {$entry@key}
30 {menu data=$entry level=$level+1}
30 {menu data=$entry level=$level+1}
31 {else}
31 {else}
32 {$entry}
32 {$entry}
33 {/if}
33 {/if}
34 {/foreach}
34 {/foreach}
35 {/function}
35 {/function}
36 {/if}</textarea></form>
36 {/if}</textarea></form>
37
37
38 <script>
38 <script>
39 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
39 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
40 lineNumbers: true,
40 lineNumbers: true,
41 mode: "smarty"
41 mode: "smarty"
42 });
42 });
43 </script>
43 </script>
44
44
45 <br />
45 <br />
46
46
47 <h3>Smarty 2, custom delimiters</h3>
47 <h3>Smarty 2, custom delimiters</h3>
48 <form><textarea id="code2" name="code2">
48 <form><textarea id="code2" name="code2">
49 {--extends file="parent.tpl"--}
49 {--extends file="parent.tpl"--}
50 {--include file="template.tpl"--}
50 {--include file="template.tpl"--}
51
51
52 {--* some example Smarty content *--}
52 {--* some example Smarty content *--}
53 {--if isset($name) && $name == 'Blog'--}
53 {--if isset($name) && $name == 'Blog'--}
54 This is a {--$var--}.
54 This is a {--$var--}.
55 {--$integer = 451--}, {--$array[] = "a"--}, {--$stringvar = "string"--}
55 {--$integer = 451--}, {--$array[] = "a"--}, {--$stringvar = "string"--}
56 {--assign var='bob' value=$var.prop--}
56 {--assign var='bob' value=$var.prop--}
57 {--elseif $name == $foo--}
57 {--elseif $name == $foo--}
58 {--function name=menu level=0--}
58 {--function name=menu level=0--}
59 {--foreach $data as $entry--}
59 {--foreach $data as $entry--}
60 {--if is_array($entry)--}
60 {--if is_array($entry)--}
61 - {--$entry@key--}
61 - {--$entry@key--}
62 {--menu data=$entry level=$level+1--}
62 {--menu data=$entry level=$level+1--}
63 {--else--}
63 {--else--}
64 {--$entry--}
64 {--$entry--}
65 {--/if--}
65 {--/if--}
66 {--/foreach--}
66 {--/foreach--}
67 {--/function--}
67 {--/function--}
68 {--/if--}</textarea></form>
68 {--/if--}</textarea></form>
69
69
70 <script>
70 <script>
71 var editor = CodeMirror.fromTextArea(document.getElementById("code2"), {
71 var editor = CodeMirror.fromTextArea(document.getElementById("code2"), {
72 lineNumbers: true,
72 lineNumbers: true,
73 mode: {
73 mode: {
74 name: "smarty",
74 name: "smarty",
75 leftDelimiter: "{--",
75 leftDelimiter: "{--",
76 rightDelimiter: "--}"
76 rightDelimiter: "--}"
77 }
77 }
78 });
78 });
79 </script>
79 </script>
80
80
81 <br />
81 <br />
82
82
83 <h3>Smarty 3</h3>
83 <h3>Smarty 3</h3>
84
84
85 <textarea id="code3" name="code3">
85 <textarea id="code3" name="code3">
86 Nested tags {$foo={counter one=1 two={inception}}+3} are now valid in Smarty 3.
86 Nested tags {$foo={counter one=1 two={inception}}+3} are now valid in Smarty 3.
87
87
88 <script>
88 <script>
89 function test() {
89 function test() {
90 console.log("Smarty 3 permits single curly braces followed by whitespace to NOT slip into Smarty mode.");
90 console.log("Smarty 3 permits single curly braces followed by whitespace to NOT slip into Smarty mode.");
91 }
91 }
92 </script>
92 </script>
93
93
94 {assign var=foo value=[1,2,3]}
94 {assign var=foo value=[1,2,3]}
95 {assign var=foo value=['y'=>'yellow','b'=>'blue']}
95 {assign var=foo value=['y'=>'yellow','b'=>'blue']}
96 {assign var=foo value=[1,[9,8],3]}
96 {assign var=foo value=[1,[9,8],3]}
97
97
98 {$foo=$bar+2} {* a comment *}
98 {$foo=$bar+2} {* a comment *}
99 {$foo.bar=1} {* another comment *}
99 {$foo.bar=1} {* another comment *}
100 {$foo = myfunct(($x+$y)*3)}
100 {$foo = myfunct(($x+$y)*3)}
101 {$foo = strlen($bar)}
101 {$foo = strlen($bar)}
102 {$foo.bar.baz=1}, {$foo[]=1}
102 {$foo.bar.baz=1}, {$foo[]=1}
103
103
104 Smarty "dot" syntax (note: embedded {} are used to address ambiguities):
104 Smarty "dot" syntax (note: embedded {} are used to address ambiguities):
105
105
106 {$foo.a.b.c} => $foo['a']['b']['c']
106 {$foo.a.b.c} => $foo['a']['b']['c']
107 {$foo.a.$b.c} => $foo['a'][$b]['c']
107 {$foo.a.$b.c} => $foo['a'][$b]['c']
108 {$foo.a.{$b+4}.c} => $foo['a'][$b+4]['c']
108 {$foo.a.{$b+4}.c} => $foo['a'][$b+4]['c']
109 {$foo.a.{$b.c}} => $foo['a'][$b['c']]
109 {$foo.a.{$b.c}} => $foo['a'][$b['c']]
110
110
111 {$object->method1($x)->method2($y)}</textarea>
111 {$object->method1($x)->method2($y)}</textarea>
112
112
113 <script>
113 <script>
114 var editor = CodeMirror.fromTextArea(document.getElementById("code3"), {
114 var editor = CodeMirror.fromTextArea(document.getElementById("code3"), {
115 lineNumbers: true,
115 lineNumbers: true,
116 mode: "smarty",
116 mode: "smarty",
117 smartyVersion: 3
117 smartyVersion: 3
118 });
118 });
119 </script>
119 </script>
120
120
121
121
122 <p>A plain text/Smarty version 2 or 3 mode, which allows for custom delimiter tags.</p>
122 <p>A plain text/Smarty version 2 or 3 mode, which allows for custom delimiter tags.</p>
123
123
124 <p><strong>MIME types defined:</strong> <code>text/x-smarty</code></p>
124 <p><strong>MIME types defined:</strong> <code>text/x-smarty</code></p>
125 </body>
125 </body>
126 </html>
126 </html>
@@ -1,68 +1,68 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>SQL Mode for CodeMirror</title>
5 <title>SQL Mode for CodeMirror</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css" />
6 <link rel="stylesheet" href="../../lib/codemirror.css" />
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="sql.js"></script>
8 <script src="sql.js"></script>
9 <style>
9 <style>
10 .CodeMirror {
10 .CodeMirror {
11 border-top: 1px solid black;
11 border-top: 1px solid black;
12 border-bottom: 1px solid black;
12 border-bottom: 1px solid black;
13 }
13 }
14 </style>
14 </style>
15 <link rel="stylesheet" href="../../doc/docs.css">
15 <link rel="stylesheet" href="../../doc/docs.css">
16 <script>
16 <script>
17 var init = function() {
17 var init = function() {
18 var mime = 'text/x-mariadb';
18 var mime = 'text/x-mariadb';
19
19
20 // get mime type
20 // get mime type
21 if (window.location.href.indexOf('mime=') > -1) {
21 if (window.location.href.indexOf('mime=') > -1) {
22 mime = window.location.href.substr(window.location.href.indexOf('mime=') + 5);
22 mime = window.location.href.substr(window.location.href.indexOf('mime=') + 5);
23 }
23 }
24
24
25 window.editor = CodeMirror.fromTextArea(document.getElementById('code'), {
25 window.editor = CodeMirror.fromTextArea(document.getElementById('code'), {
26 mode: mime,
26 mode: mime,
27 indentWithTabs: true,
27 indentWithTabs: true,
28 smartIndent: true,
28 smartIndent: true,
29 lineNumbers: true,
29 lineNumbers: true,
30 matchBrackets : true,
30 matchBrackets : true,
31 autofocus: true
31 autofocus: true
32 });
32 });
33 };
33 };
34 </script>
34 </script>
35 </head>
35 </head>
36 <body onload="init();">
36 <body onload="init();">
37 <h1>SQL Mode for CodeMirror</h1>
37 <h1>SQL Mode for CodeMirror</h1>
38 <form>
38 <form>
39 <textarea id="code" name="code">-- SQL Mode for CodeMirror
39 <textarea id="code" name="code">-- SQL Mode for CodeMirror
40 SELECT SQL_NO_CACHE DISTINCT
40 SELECT SQL_NO_CACHE DISTINCT
41 @var1 AS `val1`, @'val2', @global.'sql_mode',
41 @var1 AS `val1`, @'val2', @global.'sql_mode',
42 1.1 AS `float_val`, .14 AS `another_float`, 0.09e3 AS `int_with_esp`,
42 1.1 AS `float_val`, .14 AS `another_float`, 0.09e3 AS `int_with_esp`,
43 0xFA5 AS `hex`, x'fa5' AS `hex2`, 0b101 AS `bin`, b'101' AS `bin2`,
43 0xFA5 AS `hex`, x'fa5' AS `hex2`, 0b101 AS `bin`, b'101' AS `bin2`,
44 DATE '1994-01-01' AS `sql_date`, { T "1994-01-01" } AS `odbc_date`,
44 DATE '1994-01-01' AS `sql_date`, { T "1994-01-01" } AS `odbc_date`,
45 'my string', _utf8'your string', N'her string',
45 'my string', _utf8'your string', N'her string',
46 TRUE, FALSE, UNKNOWN
46 TRUE, FALSE, UNKNOWN
47 FROM DUAL
47 FROM DUAL
48 -- space needed after '--'
48 -- space needed after '--'
49 # 1 line comment
49 # 1 line comment
50 /* multiline
50 /* multiline
51 comment! */
51 comment! */
52 LIMIT 1 OFFSET 0;
52 LIMIT 1 OFFSET 0;
53 </textarea>
53 </textarea>
54 </form>
54 </form>
55 <p><strong>MIME types defined:</strong>
55 <p><strong>MIME types defined:</strong>
56 <code><a href="?mime=text/x-sql">text/x-sql</a></code>,
56 <code><a href="?mime=text/x-sql">text/x-sql</a></code>,
57 <code><a href="?mime=text/x-mysql">text/x-mysql</a></code>,
57 <code><a href="?mime=text/x-mysql">text/x-mysql</a></code>,
58 <code><a href="?mime=text/x-mariadb">text/x-mariadb</a></code>,
58 <code><a href="?mime=text/x-mariadb">text/x-mariadb</a></code>,
59 <code><a href="?mime=text/x-cassandra">text/x-cassandra</a></code>,
59 <code><a href="?mime=text/x-cassandra">text/x-cassandra</a></code>,
60 <code><a href="?mime=text/x-plsql">text/x-plsql</a></code>.
60 <code><a href="?mime=text/x-plsql">text/x-plsql</a></code>.
61 </p>
61 </p>
62 <p>
62 <p>
63 <strong>Tests:</strong>
63 <strong>Tests:</strong>
64 <a href="../../test/index.html#sql_*">normal</a>,
64 <a href="../../test/index.html#sql_*">normal</a>,
65 <a href="../../test/index.html#verbose,sql_*">verbose</a>.
65 <a href="../../test/index.html#verbose,sql_*">verbose</a>.
66 </p>
66 </p>
67 </body>
67 </body>
68 </html>
68 </html>
@@ -1,98 +1,98 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: sTeX mode</title>
5 <title>CodeMirror: sTeX mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="stex.js"></script>
8 <script src="stex.js"></script>
9 <style>.CodeMirror {background: #f8f8f8;}</style>
9 <style>.CodeMirror {background: #f8f8f8;}</style>
10 <link rel="stylesheet" href="../../doc/docs.css">
10 <link rel="stylesheet" href="../../doc/docs.css">
11 </head>
11 </head>
12 <body>
12 <body>
13 <h1>CodeMirror: sTeX mode</h1>
13 <h1>CodeMirror: sTeX mode</h1>
14 <form><textarea id="code" name="code">
14 <form><textarea id="code" name="code">
15 \begin{module}[id=bbt-size]
15 \begin{module}[id=bbt-size]
16 \importmodule[balanced-binary-trees]{balanced-binary-trees}
16 \importmodule[balanced-binary-trees]{balanced-binary-trees}
17 \importmodule[\KWARCslides{dmath/en/cardinality}]{cardinality}
17 \importmodule[\KWARCslides{dmath/en/cardinality}]{cardinality}
18
18
19 \begin{frame}
19 \begin{frame}
20 \frametitle{Size Lemma for Balanced Trees}
20 \frametitle{Size Lemma for Balanced Trees}
21 \begin{itemize}
21 \begin{itemize}
22 \item
22 \item
23 \begin{assertion}[id=size-lemma,type=lemma]
23 \begin{assertion}[id=size-lemma,type=lemma]
24 Let $G=\tup{V,E}$ be a \termref[cd=binary-trees]{balanced binary tree}
24 Let $G=\tup{V,E}$ be a \termref[cd=binary-trees]{balanced binary tree}
25 of \termref[cd=graph-depth,name=vertex-depth]{depth}$n>i$, then the set
25 of \termref[cd=graph-depth,name=vertex-depth]{depth}$n>i$, then the set
26 $\defeq{\livar{V}i}{\setst{\inset{v}{V}}{\gdepth{v} = i}}$ of
26 $\defeq{\livar{V}i}{\setst{\inset{v}{V}}{\gdepth{v} = i}}$ of
27 \termref[cd=graphs-intro,name=node]{nodes} at
27 \termref[cd=graphs-intro,name=node]{nodes} at
28 \termref[cd=graph-depth,name=vertex-depth]{depth} $i$ has
28 \termref[cd=graph-depth,name=vertex-depth]{depth} $i$ has
29 \termref[cd=cardinality,name=cardinality]{cardinality} $\power2i$.
29 \termref[cd=cardinality,name=cardinality]{cardinality} $\power2i$.
30 \end{assertion}
30 \end{assertion}
31 \item
31 \item
32 \begin{sproof}[id=size-lemma-pf,proofend=,for=size-lemma]{via induction over the depth $i$.}
32 \begin{sproof}[id=size-lemma-pf,proofend=,for=size-lemma]{via induction over the depth $i$.}
33 \begin{spfcases}{We have to consider two cases}
33 \begin{spfcases}{We have to consider two cases}
34 \begin{spfcase}{$i=0$}
34 \begin{spfcase}{$i=0$}
35 \begin{spfstep}[display=flow]
35 \begin{spfstep}[display=flow]
36 then $\livar{V}i=\set{\livar{v}r}$, where $\livar{v}r$ is the root, so
36 then $\livar{V}i=\set{\livar{v}r}$, where $\livar{v}r$ is the root, so
37 $\eq{\card{\livar{V}0},\card{\set{\livar{v}r}},1,\power20}$.
37 $\eq{\card{\livar{V}0},\card{\set{\livar{v}r}},1,\power20}$.
38 \end{spfstep}
38 \end{spfstep}
39 \end{spfcase}
39 \end{spfcase}
40 \begin{spfcase}{$i>0$}
40 \begin{spfcase}{$i>0$}
41 \begin{spfstep}[display=flow]
41 \begin{spfstep}[display=flow]
42 then $\livar{V}{i-1}$ contains $\power2{i-1}$ vertexes
42 then $\livar{V}{i-1}$ contains $\power2{i-1}$ vertexes
43 \begin{justification}[method=byIH](IH)\end{justification}
43 \begin{justification}[method=byIH](IH)\end{justification}
44 \end{spfstep}
44 \end{spfstep}
45 \begin{spfstep}
45 \begin{spfstep}
46 By the \begin{justification}[method=byDef]definition of a binary
46 By the \begin{justification}[method=byDef]definition of a binary
47 tree\end{justification}, each $\inset{v}{\livar{V}{i-1}}$ is a leaf or has
47 tree\end{justification}, each $\inset{v}{\livar{V}{i-1}}$ is a leaf or has
48 two children that are at depth $i$.
48 two children that are at depth $i$.
49 \end{spfstep}
49 \end{spfstep}
50 \begin{spfstep}
50 \begin{spfstep}
51 As $G$ is \termref[cd=balanced-binary-trees,name=balanced-binary-tree]{balanced} and $\gdepth{G}=n>i$, $\livar{V}{i-1}$ cannot contain
51 As $G$ is \termref[cd=balanced-binary-trees,name=balanced-binary-tree]{balanced} and $\gdepth{G}=n>i$, $\livar{V}{i-1}$ cannot contain
52 leaves.
52 leaves.
53 \end{spfstep}
53 \end{spfstep}
54 \begin{spfstep}[type=conclusion]
54 \begin{spfstep}[type=conclusion]
55 Thus $\eq{\card{\livar{V}i},{\atimes[cdot]{2,\card{\livar{V}{i-1}}}},{\atimes[cdot]{2,\power2{i-1}}},\power2i}$.
55 Thus $\eq{\card{\livar{V}i},{\atimes[cdot]{2,\card{\livar{V}{i-1}}}},{\atimes[cdot]{2,\power2{i-1}}},\power2i}$.
56 \end{spfstep}
56 \end{spfstep}
57 \end{spfcase}
57 \end{spfcase}
58 \end{spfcases}
58 \end{spfcases}
59 \end{sproof}
59 \end{sproof}
60 \item
60 \item
61 \begin{assertion}[id=fbbt,type=corollary]
61 \begin{assertion}[id=fbbt,type=corollary]
62 A fully balanced tree of depth $d$ has $\power2{d+1}-1$ nodes.
62 A fully balanced tree of depth $d$ has $\power2{d+1}-1$ nodes.
63 \end{assertion}
63 \end{assertion}
64 \item
64 \item
65 \begin{sproof}[for=fbbt,id=fbbt-pf]{}
65 \begin{sproof}[for=fbbt,id=fbbt-pf]{}
66 \begin{spfstep}
66 \begin{spfstep}
67 Let $\defeq{G}{\tup{V,E}}$ be a fully balanced tree
67 Let $\defeq{G}{\tup{V,E}}$ be a fully balanced tree
68 \end{spfstep}
68 \end{spfstep}
69 \begin{spfstep}
69 \begin{spfstep}
70 Then $\card{V}=\Sumfromto{i}1d{\power2i}= \power2{d+1}-1$.
70 Then $\card{V}=\Sumfromto{i}1d{\power2i}= \power2{d+1}-1$.
71 \end{spfstep}
71 \end{spfstep}
72 \end{sproof}
72 \end{sproof}
73 \end{itemize}
73 \end{itemize}
74 \end{frame}
74 \end{frame}
75 \begin{note}
75 \begin{note}
76 \begin{omtext}[type=conclusion,for=binary-tree]
76 \begin{omtext}[type=conclusion,for=binary-tree]
77 This shows that balanced binary trees grow in breadth very quickly, a consequence of
77 This shows that balanced binary trees grow in breadth very quickly, a consequence of
78 this is that they are very shallow (and this compute very fast), which is the essence of
78 this is that they are very shallow (and this compute very fast), which is the essence of
79 the next result.
79 the next result.
80 \end{omtext}
80 \end{omtext}
81 \end{note}
81 \end{note}
82 \end{module}
82 \end{module}
83
83
84 %%% Local Variables:
84 %%% Local Variables:
85 %%% mode: LaTeX
85 %%% mode: LaTeX
86 %%% TeX-master: "all"
86 %%% TeX-master: "all"
87 %%% End: \end{document}
87 %%% End: \end{document}
88 </textarea></form>
88 </textarea></form>
89 <script>
89 <script>
90 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
90 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
91 </script>
91 </script>
92
92
93 <p><strong>MIME types defined:</strong> <code>text/x-stex</code>.</p>
93 <p><strong>MIME types defined:</strong> <code>text/x-stex</code>.</p>
94
94
95 <p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#stex_*">normal</a>, <a href="../../test/index.html#verbose,stex_*">verbose</a>.</p>
95 <p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#stex_*">normal</a>, <a href="../../test/index.html#verbose,stex_*">verbose</a>.</p>
96
96
97 </body>
97 </body>
98 </html>
98 </html>
@@ -1,129 +1,129 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: Tcl mode</title>
5 <title>CodeMirror: Tcl mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="tcl.js"></script>
8 <script src="tcl.js"></script>
9 <link rel="stylesheet" href="../../theme/night.css">
9 <link rel="stylesheet" href="../../theme/night.css">
10 <link rel="stylesheet" href="../../doc/docs.css">
10 <link rel="stylesheet" href="../../doc/docs.css">
11 </head>
11 </head>
12 <body>
12 <body>
13 <h1>CodeMirror: Tcl mode</h1>
13 <h1>CodeMirror: Tcl mode</h1>
14 <form><textarea id="code" name="code">
14 <form><textarea id="code" name="code">
15 ##############################################################################################
15 ##############################################################################################
16 ## ## whois.tcl for eggdrop by Ford_Lawnmower irc.geekshed.net #Script-Help ## ##
16 ## ## whois.tcl for eggdrop by Ford_Lawnmower irc.geekshed.net #Script-Help ## ##
17 ##############################################################################################
17 ##############################################################################################
18 ## To use this script you must set channel flag +whois (ie .chanset #chan +whois) ##
18 ## To use this script you must set channel flag +whois (ie .chanset #chan +whois) ##
19 ##############################################################################################
19 ##############################################################################################
20 ## ____ __ ########################################### ##
20 ## ____ __ ########################################### ##
21 ## / __/___ _ ___ _ ___/ /____ ___ ___ ########################################### ##
21 ## / __/___ _ ___ _ ___/ /____ ___ ___ ########################################### ##
22 ## / _/ / _ `// _ `// _ // __// _ \ / _ \ ########################################### ##
22 ## / _/ / _ `// _ `// _ // __// _ \ / _ \ ########################################### ##
23 ## /___/ \_, / \_, / \_,_//_/ \___// .__/ ########################################### ##
23 ## /___/ \_, / \_, / \_,_//_/ \___// .__/ ########################################### ##
24 ## /___/ /___/ /_/ ########################################### ##
24 ## /___/ /___/ /_/ ########################################### ##
25 ## ########################################### ##
25 ## ########################################### ##
26 ##############################################################################################
26 ##############################################################################################
27 ## ## Start Setup. ## ##
27 ## ## Start Setup. ## ##
28 ##############################################################################################
28 ##############################################################################################
29 namespace eval whois {
29 namespace eval whois {
30 ## change cmdchar to the trigger you want to use ## ##
30 ## change cmdchar to the trigger you want to use ## ##
31 variable cmdchar "!"
31 variable cmdchar "!"
32 ## change command to the word trigger you would like to use. ## ##
32 ## change command to the word trigger you would like to use. ## ##
33 ## Keep in mind, This will also change the .chanset +/-command ## ##
33 ## Keep in mind, This will also change the .chanset +/-command ## ##
34 variable command "whois"
34 variable command "whois"
35 ## change textf to the colors you want for the text. ## ##
35 ## change textf to the colors you want for the text. ## ##
36 variable textf "\017\00304"
36 variable textf "\017\00304"
37 ## change tagf to the colors you want for tags: ## ##
37 ## change tagf to the colors you want for tags: ## ##
38 variable tagf "\017\002"
38 variable tagf "\017\002"
39 ## Change logo to the logo you want at the start of the line. ## ##
39 ## Change logo to the logo you want at the start of the line. ## ##
40 variable logo "\017\00304\002\[\00306W\003hois\00304\]\017"
40 variable logo "\017\00304\002\[\00306W\003hois\00304\]\017"
41 ## Change lineout to the results you want. Valid results are channel users modes topic ## ##
41 ## Change lineout to the results you want. Valid results are channel users modes topic ## ##
42 variable lineout "channel users modes topic"
42 variable lineout "channel users modes topic"
43 ##############################################################################################
43 ##############################################################################################
44 ## ## End Setup. ## ##
44 ## ## End Setup. ## ##
45 ##############################################################################################
45 ##############################################################################################
46 variable channel ""
46 variable channel ""
47 setudef flag $whois::command
47 setudef flag $whois::command
48 bind pub -|- [string trimleft $whois::cmdchar]${whois::command} whois::list
48 bind pub -|- [string trimleft $whois::cmdchar]${whois::command} whois::list
49 bind raw -|- "311" whois::311
49 bind raw -|- "311" whois::311
50 bind raw -|- "312" whois::312
50 bind raw -|- "312" whois::312
51 bind raw -|- "319" whois::319
51 bind raw -|- "319" whois::319
52 bind raw -|- "317" whois::317
52 bind raw -|- "317" whois::317
53 bind raw -|- "313" whois::multi
53 bind raw -|- "313" whois::multi
54 bind raw -|- "310" whois::multi
54 bind raw -|- "310" whois::multi
55 bind raw -|- "335" whois::multi
55 bind raw -|- "335" whois::multi
56 bind raw -|- "301" whois::301
56 bind raw -|- "301" whois::301
57 bind raw -|- "671" whois::multi
57 bind raw -|- "671" whois::multi
58 bind raw -|- "320" whois::multi
58 bind raw -|- "320" whois::multi
59 bind raw -|- "401" whois::multi
59 bind raw -|- "401" whois::multi
60 bind raw -|- "318" whois::318
60 bind raw -|- "318" whois::318
61 bind raw -|- "307" whois::307
61 bind raw -|- "307" whois::307
62 }
62 }
63 proc whois::311 {from key text} {
63 proc whois::311 {from key text} {
64 if {[regexp -- {^[^\s]+\s(.+?)\s(.+?)\s(.+?)\s\*\s\:(.+)$} $text wholematch nick ident host realname]} {
64 if {[regexp -- {^[^\s]+\s(.+?)\s(.+?)\s(.+?)\s\*\s\:(.+)$} $text wholematch nick ident host realname]} {
65 putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Host:${whois::textf} \
65 putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Host:${whois::textf} \
66 $nick \(${ident}@${host}\) ${whois::tagf}Realname:${whois::textf} $realname"
66 $nick \(${ident}@${host}\) ${whois::tagf}Realname:${whois::textf} $realname"
67 }
67 }
68 }
68 }
69 proc whois::multi {from key text} {
69 proc whois::multi {from key text} {
70 if {[regexp {\:(.*)$} $text match $key]} {
70 if {[regexp {\:(.*)$} $text match $key]} {
71 putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Note:${whois::textf} [subst $$key]"
71 putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Note:${whois::textf} [subst $$key]"
72 return 1
72 return 1
73 }
73 }
74 }
74 }
75 proc whois::312 {from key text} {
75 proc whois::312 {from key text} {
76 regexp {([^\s]+)\s\:} $text match server
76 regexp {([^\s]+)\s\:} $text match server
77 putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Server:${whois::textf} $server"
77 putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Server:${whois::textf} $server"
78 }
78 }
79 proc whois::319 {from key text} {
79 proc whois::319 {from key text} {
80 if {[regexp {.+\:(.+)$} $text match channels]} {
80 if {[regexp {.+\:(.+)$} $text match channels]} {
81 putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Channels:${whois::textf} $channels"
81 putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Channels:${whois::textf} $channels"
82 }
82 }
83 }
83 }
84 proc whois::317 {from key text} {
84 proc whois::317 {from key text} {
85 if {[regexp -- {.*\s(\d+)\s(\d+)\s\:} $text wholematch idle signon]} {
85 if {[regexp -- {.*\s(\d+)\s(\d+)\s\:} $text wholematch idle signon]} {
86 putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Connected:${whois::textf} \
86 putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Connected:${whois::textf} \
87 [ctime $signon] ${whois::tagf}Idle:${whois::textf} [duration $idle]"
87 [ctime $signon] ${whois::tagf}Idle:${whois::textf} [duration $idle]"
88 }
88 }
89 }
89 }
90 proc whois::301 {from key text} {
90 proc whois::301 {from key text} {
91 if {[regexp {^.+\s[^\s]+\s\:(.*)$} $text match awaymsg]} {
91 if {[regexp {^.+\s[^\s]+\s\:(.*)$} $text match awaymsg]} {
92 putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Away:${whois::textf} $awaymsg"
92 putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Away:${whois::textf} $awaymsg"
93 }
93 }
94 }
94 }
95 proc whois::318 {from key text} {
95 proc whois::318 {from key text} {
96 namespace eval whois {
96 namespace eval whois {
97 variable channel ""
97 variable channel ""
98 }
98 }
99 variable whois::channel ""
99 variable whois::channel ""
100 }
100 }
101 proc whois::307 {from key text} {
101 proc whois::307 {from key text} {
102 putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Services:${whois::textf} Registered Nick"
102 putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Services:${whois::textf} Registered Nick"
103 }
103 }
104 proc whois::list {nick host hand chan text} {
104 proc whois::list {nick host hand chan text} {
105 if {[lsearch -exact [channel info $chan] "+${whois::command}"] != -1} {
105 if {[lsearch -exact [channel info $chan] "+${whois::command}"] != -1} {
106 namespace eval whois {
106 namespace eval whois {
107 variable channel ""
107 variable channel ""
108 }
108 }
109 variable whois::channel $chan
109 variable whois::channel $chan
110 putserv "WHOIS $text"
110 putserv "WHOIS $text"
111 }
111 }
112 }
112 }
113 putlog "\002*Loaded* \017\00304\002\[\00306W\003hois\00304\]\017 \002by \
113 putlog "\002*Loaded* \017\00304\002\[\00306W\003hois\00304\]\017 \002by \
114 Ford_Lawnmower irc.GeekShed.net #Script-Help"
114 Ford_Lawnmower irc.GeekShed.net #Script-Help"
115 </textarea></form>
115 </textarea></form>
116 <script>
116 <script>
117 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
117 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
118 tabMode: "indent",
118 tabMode: "indent",
119 theme: "night",
119 theme: "night",
120 lineNumbers: true,
120 lineNumbers: true,
121 indentUnit: 2,
121 indentUnit: 2,
122 mode: "text/x-tcl"
122 mode: "text/x-tcl"
123 });
123 });
124 </script>
124 </script>
125
125
126 <p><strong>MIME types defined:</strong> <code>text/x-tcl</code>.</p>
126 <p><strong>MIME types defined:</strong> <code>text/x-tcl</code>.</p>
127
127
128 </body>
128 </body>
129 </html>
129 </html>
@@ -1,142 +1,142 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: TiddlyWiki mode</title>
5 <title>CodeMirror: TiddlyWiki mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="../../addon/edit/matchbrackets.js"></script>
8 <script src="../../addon/edit/matchbrackets.js"></script>
9 <script src="tiddlywiki.js"></script>
9 <script src="tiddlywiki.js"></script>
10 <link rel="stylesheet" href="tiddlywiki.css">
10 <link rel="stylesheet" href="tiddlywiki.css">
11 <link rel="stylesheet" href="../../doc/docs.css">
11 <link rel="stylesheet" href="../../doc/docs.css">
12 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
12 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
13 </head>
13 </head>
14 <body>
14 <body>
15 <h1>CodeMirror: TiddlyWiki mode</h1>
15 <h1>CodeMirror: TiddlyWiki mode</h1>
16
16
17 <div><textarea id="code" name="code">
17 <div><textarea id="code" name="code">
18 !TiddlyWiki Formatting
18 !TiddlyWiki Formatting
19 * Rendered versions can be found at: http://www.tiddlywiki.com/#Reference
19 * Rendered versions can be found at: http://www.tiddlywiki.com/#Reference
20
20
21 |!Option | !Syntax |
21 |!Option | !Syntax |
22 |bold font | ''bold'' |
22 |bold font | ''bold'' |
23 |italic type | //italic// |
23 |italic type | //italic// |
24 |underlined text | __underlined__ |
24 |underlined text | __underlined__ |
25 |strikethrough text | --strikethrough-- |
25 |strikethrough text | --strikethrough-- |
26 |superscript text | super^^script^^ |
26 |superscript text | super^^script^^ |
27 |subscript text | sub~~script~~ |
27 |subscript text | sub~~script~~ |
28 |highlighted text | @@highlighted@@ |
28 |highlighted text | @@highlighted@@ |
29 |preformatted text | {{{preformatted}}} |
29 |preformatted text | {{{preformatted}}} |
30
30
31 !Block Elements
31 !Block Elements
32 <<<
32 <<<
33 !Heading 1
33 !Heading 1
34
34
35 !!Heading 2
35 !!Heading 2
36
36
37 !!!Heading 3
37 !!!Heading 3
38
38
39 !!!!Heading 4
39 !!!!Heading 4
40
40
41 !!!!!Heading 5
41 !!!!!Heading 5
42 <<<
42 <<<
43
43
44 !!Lists
44 !!Lists
45 <<<
45 <<<
46 * unordered list, level 1
46 * unordered list, level 1
47 ** unordered list, level 2
47 ** unordered list, level 2
48 *** unordered list, level 3
48 *** unordered list, level 3
49
49
50 # ordered list, level 1
50 # ordered list, level 1
51 ## ordered list, level 2
51 ## ordered list, level 2
52 ### unordered list, level 3
52 ### unordered list, level 3
53
53
54 ; definition list, term
54 ; definition list, term
55 : definition list, description
55 : definition list, description
56 <<<
56 <<<
57
57
58 !!Blockquotes
58 !!Blockquotes
59 <<<
59 <<<
60 > blockquote, level 1
60 > blockquote, level 1
61 >> blockquote, level 2
61 >> blockquote, level 2
62 >>> blockquote, level 3
62 >>> blockquote, level 3
63
63
64 > blockquote
64 > blockquote
65 <<<
65 <<<
66
66
67 !!Preformatted Text
67 !!Preformatted Text
68 <<<
68 <<<
69 {{{
69 {{{
70 preformatted (e.g. code)
70 preformatted (e.g. code)
71 }}}
71 }}}
72 <<<
72 <<<
73
73
74 !!Code Sections
74 !!Code Sections
75 <<<
75 <<<
76 {{{
76 {{{
77 Text style code
77 Text style code
78 }}}
78 }}}
79
79
80 //{{{
80 //{{{
81 JS styled code. TiddlyWiki mixed mode should support highlighter switching in the future.
81 JS styled code. TiddlyWiki mixed mode should support highlighter switching in the future.
82 //}}}
82 //}}}
83
83
84 <!--{{{-->
84 <!--{{{-->
85 XML styled code. TiddlyWiki mixed mode should support highlighter switching in the future.
85 XML styled code. TiddlyWiki mixed mode should support highlighter switching in the future.
86 <!--}}}-->
86 <!--}}}-->
87 <<<
87 <<<
88
88
89 !!Tables
89 !!Tables
90 <<<
90 <<<
91 |CssClass|k
91 |CssClass|k
92 |!heading column 1|!heading column 2|
92 |!heading column 1|!heading column 2|
93 |row 1, column 1|row 1, column 2|
93 |row 1, column 1|row 1, column 2|
94 |row 2, column 1|row 2, column 2|
94 |row 2, column 1|row 2, column 2|
95 |>|COLSPAN|
95 |>|COLSPAN|
96 |ROWSPAN| ... |
96 |ROWSPAN| ... |
97 |~| ... |
97 |~| ... |
98 |CssProperty:value;...| ... |
98 |CssProperty:value;...| ... |
99 |caption|c
99 |caption|c
100
100
101 ''Annotation:''
101 ''Annotation:''
102 * The {{{>}}} marker creates a "colspan", causing the current cell to merge with the one to the right.
102 * The {{{>}}} marker creates a "colspan", causing the current cell to merge with the one to the right.
103 * The {{{~}}} marker creates a "rowspan", causing the current cell to merge with the one above.
103 * The {{{~}}} marker creates a "rowspan", causing the current cell to merge with the one above.
104 <<<
104 <<<
105 !!Images /% TODO %/
105 !!Images /% TODO %/
106 cf. [[TiddlyWiki.com|http://www.tiddlywiki.com/#EmbeddedImages]]
106 cf. [[TiddlyWiki.com|http://www.tiddlywiki.com/#EmbeddedImages]]
107
107
108 !Hyperlinks
108 !Hyperlinks
109 * [[WikiWords|WikiWord]] are automatically transformed to hyperlinks to the respective tiddler
109 * [[WikiWords|WikiWord]] are automatically transformed to hyperlinks to the respective tiddler
110 ** the automatic transformation can be suppressed by preceding the respective WikiWord with a tilde ({{{~}}}): {{{~WikiWord}}}
110 ** the automatic transformation can be suppressed by preceding the respective WikiWord with a tilde ({{{~}}}): {{{~WikiWord}}}
111 * [[PrettyLinks]] are enclosed in square brackets and contain the desired tiddler name: {{{[[tiddler name]]}}}
111 * [[PrettyLinks]] are enclosed in square brackets and contain the desired tiddler name: {{{[[tiddler name]]}}}
112 ** optionally, a custom title or description can be added, separated by a pipe character ({{{|}}}): {{{[[title|target]]}}}<br>'''N.B.:''' In this case, the target can also be any website (i.e. URL).
112 ** optionally, a custom title or description can be added, separated by a pipe character ({{{|}}}): {{{[[title|target]]}}}<br>'''N.B.:''' In this case, the target can also be any website (i.e. URL).
113
113
114 !Custom Styling
114 !Custom Styling
115 * {{{@@CssProperty:value;CssProperty:value;...@@}}}<br>''N.B.:'' CSS color definitions should use lowercase letters to prevent the inadvertent creation of WikiWords.
115 * {{{@@CssProperty:value;CssProperty:value;...@@}}}<br>''N.B.:'' CSS color definitions should use lowercase letters to prevent the inadvertent creation of WikiWords.
116 * <html><code>{{customCssClass{...}}}</code></html>
116 * <html><code>{{customCssClass{...}}}</code></html>
117 * raw HTML can be inserted by enclosing the respective code in HTML tags: {{{<html> ... </html>}}}
117 * raw HTML can be inserted by enclosing the respective code in HTML tags: {{{<html> ... </html>}}}
118
118
119 !Special Markers
119 !Special Markers
120 * {{{<br>}}} forces a manual line break
120 * {{{<br>}}} forces a manual line break
121 * {{{----}}} creates a horizontal ruler
121 * {{{----}}} creates a horizontal ruler
122 * [[HTML entities|http://www.tiddlywiki.com/#HtmlEntities]]
122 * [[HTML entities|http://www.tiddlywiki.com/#HtmlEntities]]
123 * [[HTML entities local|HtmlEntities]]
123 * [[HTML entities local|HtmlEntities]]
124 * {{{<<macroName>>}}} calls the respective [[macro|Macros]]
124 * {{{<<macroName>>}}} calls the respective [[macro|Macros]]
125 * To hide text within a tiddler so that it is not displayed, it can be wrapped in {{{/%}}} and {{{%/}}}.<br/>This can be a useful trick for hiding drafts or annotating complex markup.
125 * To hide text within a tiddler so that it is not displayed, it can be wrapped in {{{/%}}} and {{{%/}}}.<br/>This can be a useful trick for hiding drafts or annotating complex markup.
126 * To prevent wiki markup from taking effect for a particular section, that section can be enclosed in three double quotes: e.g. {{{"""WikiWord"""}}}.
126 * To prevent wiki markup from taking effect for a particular section, that section can be enclosed in three double quotes: e.g. {{{"""WikiWord"""}}}.
127 </textarea></div>
127 </textarea></div>
128
128
129 <script>
129 <script>
130 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
130 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
131 mode: 'tiddlywiki',
131 mode: 'tiddlywiki',
132 lineNumbers: true,
132 lineNumbers: true,
133 enterMode: 'keep',
133 enterMode: 'keep',
134 matchBrackets: true
134 matchBrackets: true
135 });
135 });
136 </script>
136 </script>
137
137
138 <p>TiddlyWiki mode supports a single configuration.</p>
138 <p>TiddlyWiki mode supports a single configuration.</p>
139
139
140 <p><strong>MIME types defined:</strong> <code>text/x-tiddlywiki</code>.</p>
140 <p><strong>MIME types defined:</strong> <code>text/x-tiddlywiki</code>.</p>
141 </body>
141 </body>
142 </html>
142 </html>
@@ -1,81 +1,81 b''
1 <html xmlns="http://www.w3.org/1999/xhtml">
1 <html xmlns="http://www.w3.org/1999/xhtml">
2 <head>
2 <head>
3 <meta charset="utf-8">
3 <meta charset="utf-8">
4 <title>CodeMirror: Tiki wiki mode</title>
4 <title>CodeMirror: Tiki wiki mode</title>
5 <link rel="stylesheet" href="../../lib/codemirror.css">
5 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <script src="../../lib/codemirror.js"></script>
6 <script src="../../lib/codemirror.js"></script>
7 <script src="tiki.js"></script>
7 <script src="tiki.js"></script>
8 <link rel="stylesheet" href="tiki.css">
8 <link rel="stylesheet" href="tiki.css">
9 <link rel="stylesheet" href="../../doc/docs.css">
9 <link rel="stylesheet" href="../../doc/docs.css">
10 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
10 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
11 </head>
11 </head>
12 <body style="padding: 20px;">
12 <body style="padding: 20px;">
13 <h1>CodeMirror: Tiki wiki mode</h1>
13 <h1>CodeMirror: Tiki wiki mode</h1>
14
14
15 <div><textarea id="code" name="code">
15 <div><textarea id="code" name="code">
16 Headings
16 Headings
17 !Header 1
17 !Header 1
18 !!Header 2
18 !!Header 2
19 !!!Header 3
19 !!!Header 3
20 !!!!Header 4
20 !!!!Header 4
21 !!!!!Header 5
21 !!!!!Header 5
22 !!!!!!Header 6
22 !!!!!!Header 6
23
23
24 Styling
24 Styling
25 -=titlebar=-
25 -=titlebar=-
26 ^^ Box on multi
26 ^^ Box on multi
27 lines
27 lines
28 of content^^
28 of content^^
29 __bold__
29 __bold__
30 ''italic''
30 ''italic''
31 ===underline===
31 ===underline===
32 ::center::
32 ::center::
33 --Line Through--
33 --Line Through--
34
34
35 Operators
35 Operators
36 ~np~No parse~/np~
36 ~np~No parse~/np~
37
37
38 Link
38 Link
39 [link|desc|nocache]
39 [link|desc|nocache]
40
40
41 Wiki
41 Wiki
42 ((Wiki))
42 ((Wiki))
43 ((Wiki|desc))
43 ((Wiki|desc))
44 ((Wiki|desc|timeout))
44 ((Wiki|desc|timeout))
45
45
46 Table
46 Table
47 ||row1 col1|row1 col2|row1 col3
47 ||row1 col1|row1 col2|row1 col3
48 row2 col1|row2 col2|row2 col3
48 row2 col1|row2 col2|row2 col3
49 row3 col1|row3 col2|row3 col3||
49 row3 col1|row3 col2|row3 col3||
50
50
51 Lists:
51 Lists:
52 *bla
52 *bla
53 **bla-1
53 **bla-1
54 ++continue-bla-1
54 ++continue-bla-1
55 ***bla-2
55 ***bla-2
56 ++continue-bla-1
56 ++continue-bla-1
57 *bla
57 *bla
58 +continue-bla
58 +continue-bla
59 #bla
59 #bla
60 ** tra-la-la
60 ** tra-la-la
61 +continue-bla
61 +continue-bla
62 #bla
62 #bla
63
63
64 Plugin (standard):
64 Plugin (standard):
65 {PLUGIN(attr="my attr")}
65 {PLUGIN(attr="my attr")}
66 Plugin Body
66 Plugin Body
67 {PLUGIN}
67 {PLUGIN}
68
68
69 Plugin (inline):
69 Plugin (inline):
70 {plugin attr="my attr"}
70 {plugin attr="my attr"}
71 </textarea></div>
71 </textarea></div>
72
72
73 <script type="text/javascript">
73 <script type="text/javascript">
74 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
74 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
75 mode: 'tiki',
75 mode: 'tiki',
76 lineNumbers: true
76 lineNumbers: true
77 });
77 });
78 </script>
78 </script>
79
79
80 </body>
80 </body>
81 </html>
81 </html>
@@ -1,26 +1,26 b''
1 .cm-tw-syntaxerror {
1 .cm-tw-syntaxerror {
2 color: #FFF;
2 color: #FFF;
3 background-color: #900;
3 background-color: #900;
4 }
4 }
5
5
6 .cm-tw-deleted {
6 .cm-tw-deleted {
7 text-decoration: line-through;
7 text-decoration: line-through;
8 }
8 }
9
9
10 .cm-tw-header5 {
10 .cm-tw-header5 {
11 font-weight: bold;
11 font-weight: bold;
12 }
12 }
13 .cm-tw-listitem:first-child { /*Added first child to fix duplicate padding when highlighting*/
13 .cm-tw-listitem:first-child { /*Added first child to fix duplicate padding when highlighting*/
14 padding-left: 10px;
14 padding-left: 10px;
15 }
15 }
16
16
17 .cm-tw-box {
17 .cm-tw-box {
18 border-top-width: 0px ! important;
18 border-top-width: 0px ! important;
19 border-style: solid;
19 border-style: solid;
20 border-width: 1px;
20 border-width: 1px;
21 border-color: inherit;
21 border-color: inherit;
22 }
22 }
23
23
24 .cm-tw-underline {
24 .cm-tw-underline {
25 text-decoration: underline;
25 text-decoration: underline;
26 } No newline at end of file
26 }
@@ -1,39 +1,39 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: Turtle mode</title>
5 <title>CodeMirror: Turtle mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="turtle.js"></script>
8 <script src="turtle.js"></script>
9 <style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
9 <style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
10 <link rel="stylesheet" href="../../doc/docs.css">
10 <link rel="stylesheet" href="../../doc/docs.css">
11 </head>
11 </head>
12 <body>
12 <body>
13 <h1>CodeMirror: Turtle mode</h1>
13 <h1>CodeMirror: Turtle mode</h1>
14 <form><textarea id="code" name="code">
14 <form><textarea id="code" name="code">
15 @prefix foaf: <http://xmlns.com/foaf/0.1/> .
15 @prefix foaf: <http://xmlns.com/foaf/0.1/> .
16 @prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
16 @prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
17 @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
17 @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
18
18
19 <http://purl.org/net/bsletten>
19 <http://purl.org/net/bsletten>
20 a foaf:Person;
20 a foaf:Person;
21 foaf:interest <http://www.w3.org/2000/01/sw/>;
21 foaf:interest <http://www.w3.org/2000/01/sw/>;
22 foaf:based_near [
22 foaf:based_near [
23 geo:lat "34.0736111" ;
23 geo:lat "34.0736111" ;
24 geo:lon "-118.3994444"
24 geo:lon "-118.3994444"
25 ]
25 ]
26
26
27 </textarea></form>
27 </textarea></form>
28 <script>
28 <script>
29 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
29 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
30 mode: "text/turtle",
30 mode: "text/turtle",
31 tabMode: "indent",
31 tabMode: "indent",
32 matchBrackets: true
32 matchBrackets: true
33 });
33 });
34 </script>
34 </script>
35
35
36 <p><strong>MIME types defined:</strong> <code>text/turtle</code>.</p>
36 <p><strong>MIME types defined:</strong> <code>text/turtle</code>.</p>
37
37
38 </body>
38 </body>
39 </html>
39 </html>
@@ -1,88 +1,88 b''
1 <html>
1 <html>
2 <head>
2 <head>
3 <meta charset="utf-8">
3 <meta charset="utf-8">
4 <title>CodeMirror: VB.NET mode</title>
4 <title>CodeMirror: VB.NET mode</title>
5 <link rel="stylesheet" href="../../lib/codemirror.css">
5 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <script src="../../lib/codemirror.js"></script>
6 <script src="../../lib/codemirror.js"></script>
7 <script src="vb.js"></script>
7 <script src="vb.js"></script>
8 <link rel="stylesheet" href="../../doc/docs.css">
8 <link rel="stylesheet" href="../../doc/docs.css">
9 <link href="http://fonts.googleapis.com/css?family=Inconsolata" rel="stylesheet" type="text/css">
9 <link href="http://fonts.googleapis.com/css?family=Inconsolata" rel="stylesheet" type="text/css">
10 <style>
10 <style>
11 .CodeMirror {border: 1px solid #aaa; height:210px; height: auto;}
11 .CodeMirror {border: 1px solid #aaa; height:210px; height: auto;}
12 .CodeMirror-scroll { overflow-x: auto; overflow-y: hidden;}
12 .CodeMirror-scroll { overflow-x: auto; overflow-y: hidden;}
13 .CodeMirror pre { font-family: Inconsolata; font-size: 14px}
13 .CodeMirror pre { font-family: Inconsolata; font-size: 14px}
14 </style>
14 </style>
15 <script type="text/javascript" src="../../addon/runmode/runmode.js"></script>
15 <script type="text/javascript" src="../../addon/runmode/runmode.js"></script>
16 </head>
16 </head>
17 <body onload="init()">
17 <body onload="init()">
18 <h1>CodeMirror: VB.NET mode</h1>
18 <h1>CodeMirror: VB.NET mode</h1>
19 <script type="text/javascript">
19 <script type="text/javascript">
20 function test(golden, text) {
20 function test(golden, text) {
21 var ok = true;
21 var ok = true;
22 var i = 0;
22 var i = 0;
23 function callback(token, style, lineNo, pos){
23 function callback(token, style, lineNo, pos){
24 //console.log(String(token) + " " + String(style) + " " + String(lineNo) + " " + String(pos));
24 //console.log(String(token) + " " + String(style) + " " + String(lineNo) + " " + String(pos));
25 var result = [String(token), String(style)];
25 var result = [String(token), String(style)];
26 if (golden[i][0] != result[0] || golden[i][1] != result[1]){
26 if (golden[i][0] != result[0] || golden[i][1] != result[1]){
27 return "Error, expected: " + String(golden[i]) + ", got: " + String(result);
27 return "Error, expected: " + String(golden[i]) + ", got: " + String(result);
28 ok = false;
28 ok = false;
29 }
29 }
30 i++;
30 i++;
31 }
31 }
32 CodeMirror.runMode(text, "text/x-vb",callback);
32 CodeMirror.runMode(text, "text/x-vb",callback);
33
33
34 if (ok) return "Tests OK";
34 if (ok) return "Tests OK";
35 }
35 }
36 function testTypes() {
36 function testTypes() {
37 var golden = [['Integer','keyword'],[' ','null'],['Float','keyword']]
37 var golden = [['Integer','keyword'],[' ','null'],['Float','keyword']]
38 var text = "Integer Float";
38 var text = "Integer Float";
39 return test(golden,text);
39 return test(golden,text);
40 }
40 }
41 function testIf(){
41 function testIf(){
42 var golden = [['If','keyword'],[' ','null'],['True','keyword'],[' ','null'],['End','keyword'],[' ','null'],['If','keyword']];
42 var golden = [['If','keyword'],[' ','null'],['True','keyword'],[' ','null'],['End','keyword'],[' ','null'],['If','keyword']];
43 var text = 'If True End If';
43 var text = 'If True End If';
44 return test(golden, text);
44 return test(golden, text);
45 }
45 }
46 function testDecl(){
46 function testDecl(){
47 var golden = [['Dim','keyword'],[' ','null'],['x','variable'],[' ','null'],['as','keyword'],[' ','null'],['Integer','keyword']];
47 var golden = [['Dim','keyword'],[' ','null'],['x','variable'],[' ','null'],['as','keyword'],[' ','null'],['Integer','keyword']];
48 var text = 'Dim x as Integer';
48 var text = 'Dim x as Integer';
49 return test(golden, text);
49 return test(golden, text);
50 }
50 }
51 function testAll(){
51 function testAll(){
52 var result = "";
52 var result = "";
53
53
54 result += testTypes() + "\n";
54 result += testTypes() + "\n";
55 result += testIf() + "\n";
55 result += testIf() + "\n";
56 result += testDecl() + "\n";
56 result += testDecl() + "\n";
57 return result;
57 return result;
58
58
59 }
59 }
60 function initText(editor) {
60 function initText(editor) {
61 var content = 'Class rocket\nPrivate quality as Double\nPublic Sub launch() as String\nif quality > 0.8\nlaunch = "Successful"\nElse\nlaunch = "Failed"\nEnd If\nEnd sub\nEnd class\n';
61 var content = 'Class rocket\nPrivate quality as Double\nPublic Sub launch() as String\nif quality > 0.8\nlaunch = "Successful"\nElse\nlaunch = "Failed"\nEnd If\nEnd sub\nEnd class\n';
62 editor.setValue(content);
62 editor.setValue(content);
63 for (var i =0; i< editor.lineCount(); i++) editor.indentLine(i);
63 for (var i =0; i< editor.lineCount(); i++) editor.indentLine(i);
64 }
64 }
65 function init() {
65 function init() {
66 editor = CodeMirror.fromTextArea(document.getElementById("solution"), {
66 editor = CodeMirror.fromTextArea(document.getElementById("solution"), {
67 lineNumbers: true,
67 lineNumbers: true,
68 mode: "text/x-vb",
68 mode: "text/x-vb",
69 readOnly: false,
69 readOnly: false,
70 tabMode: "shift"
70 tabMode: "shift"
71 });
71 });
72 runTest();
72 runTest();
73 }
73 }
74 function runTest() {
74 function runTest() {
75 document.getElementById('testresult').innerHTML = testAll();
75 document.getElementById('testresult').innerHTML = testAll();
76 initText(editor);
76 initText(editor);
77
77
78 }
78 }
79 </script>
79 </script>
80
80
81
81
82 <div id="edit">
82 <div id="edit">
83 <textarea style="width:95%;height:200px;padding:5px;" name="solution" id="solution" ></textarea>
83 <textarea style="width:95%;height:200px;padding:5px;" name="solution" id="solution" ></textarea>
84 </div>
84 </div>
85 <pre id="testresult"></pre>
85 <pre id="testresult"></pre>
86 <p>MIME type defined: <code>text/x-vb</code>.</p>
86 <p>MIME type defined: <code>text/x-vb</code>.</p>
87
87
88 </body></html>
88 </body></html>
@@ -1,42 +1,41 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: VBScript mode</title>
5 <title>CodeMirror: VBScript mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="vbscript.js"></script>
8 <script src="vbscript.js"></script>
9 <link rel="stylesheet" href="../../doc/docs.css">
9 <link rel="stylesheet" href="../../doc/docs.css">
10 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
10 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
11 </head>
11 </head>
12 <body>
12 <body>
13 <h1>CodeMirror: VBScript mode</h1>
13 <h1>CodeMirror: VBScript mode</h1>
14
14
15 <div><textarea id="code" name="code">
15 <div><textarea id="code" name="code">
16 ' Pete Guhl
16 ' Pete Guhl
17 ' 03-04-2012
17 ' 03-04-2012
18 '
18 '
19 ' Basic VBScript support for codemirror2
19 ' Basic VBScript support for codemirror2
20
20
21 Const ForReading = 1, ForWriting = 2, ForAppending = 8
21 Const ForReading = 1, ForWriting = 2, ForAppending = 8
22
22
23 Call Sub020_PostBroadcastToUrbanAirship(strUserName, strPassword, intTransmitID, strResponse)
23 Call Sub020_PostBroadcastToUrbanAirship(strUserName, strPassword, intTransmitID, strResponse)
24
24
25 If Not IsNull(strResponse) AND Len(strResponse) = 0 Then
25 If Not IsNull(strResponse) AND Len(strResponse) = 0 Then
26 boolTransmitOkYN = False
26 boolTransmitOkYN = False
27 Else
27 Else
28 ' WScript.Echo "Oh Happy Day! Oh Happy DAY!"
28 ' WScript.Echo "Oh Happy Day! Oh Happy DAY!"
29 boolTransmitOkYN = True
29 boolTransmitOkYN = True
30 End If
30 End If
31 </textarea></div>
31 </textarea></div>
32
32
33 <script>
33 <script>
34 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
34 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
35 lineNumbers: true
35 lineNumbers: true
36 });
36 });
37 </script>
37 </script>
38
38
39 <p><strong>MIME types defined:</strong> <code>text/vbscript</code>.</p>
39 <p><strong>MIME types defined:</strong> <code>text/vbscript</code>.</p>
40 </body>
40 </body>
41 </html>
41 </html>
42
@@ -1,121 +1,121 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <head>
3 <head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <title>CodeMirror: Verilog mode</title>
5 <title>CodeMirror: Verilog mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
7 <script src="../../lib/codemirror.js"></script>
8 <script src="verilog.js"></script>
8 <script src="verilog.js"></script>
9 <link rel="stylesheet" href="../../doc/docs.css">
9 <link rel="stylesheet" href="../../doc/docs.css">
10 <style>.CodeMirror {border: 2px inset #dee;}</style>
10 <style>.CodeMirror {border: 2px inset #dee;}</style>
11 </head>
11 </head>
12 <body>
12 <body>
13 <h1>CodeMirror: Verilog mode</h1>
13 <h1>CodeMirror: Verilog mode</h1>
14
14
15 <form><textarea id="code" name="code">
15 <form><textarea id="code" name="code">
16 /* Verilog demo code */
16 /* Verilog demo code */
17
17
18 module butterfly
18 module butterfly
19 #(
19 #(
20 parameter WIDTH = 32,
20 parameter WIDTH = 32,
21 parameter MWIDTH = 1
21 parameter MWIDTH = 1
22 )
22 )
23 (
23 (
24 input wire clk,
24 input wire clk,
25 input wire rst_n,
25 input wire rst_n,
26 // m_in contains data that passes through this block with no change.
26 // m_in contains data that passes through this block with no change.
27 input wire [MWIDTH-1:0] m_in,
27 input wire [MWIDTH-1:0] m_in,
28 // The twiddle factor.
28 // The twiddle factor.
29 input wire signed [WIDTH-1:0] w,
29 input wire signed [WIDTH-1:0] w,
30 // XA
30 // XA
31 input wire signed [WIDTH-1:0] xa,
31 input wire signed [WIDTH-1:0] xa,
32 // XB
32 // XB
33 input wire signed [WIDTH-1:0] xb,
33 input wire signed [WIDTH-1:0] xb,
34 // Set to 1 when new data is present on inputs.
34 // Set to 1 when new data is present on inputs.
35 input wire x_nd,
35 input wire x_nd,
36 // delayed version of m_in.
36 // delayed version of m_in.
37 output reg [MWIDTH-1:0] m_out,
37 output reg [MWIDTH-1:0] m_out,
38 // YA = XA + W*XB
38 // YA = XA + W*XB
39 // YB = XA - W*XB
39 // YB = XA - W*XB
40 output wire signed [WIDTH-1:0] ya,
40 output wire signed [WIDTH-1:0] ya,
41 output wire signed [WIDTH-1:0] yb,
41 output wire signed [WIDTH-1:0] yb,
42 output reg y_nd,
42 output reg y_nd,
43 output reg error
43 output reg error
44 );
44 );
45
45
46 // Set wire to the real and imag parts for convenience.
46 // Set wire to the real and imag parts for convenience.
47 wire signed [WIDTH/2-1:0] xa_re;
47 wire signed [WIDTH/2-1:0] xa_re;
48 wire signed [WIDTH/2-1:0] xa_im;
48 wire signed [WIDTH/2-1:0] xa_im;
49 assign xa_re = xa[WIDTH-1:WIDTH/2];
49 assign xa_re = xa[WIDTH-1:WIDTH/2];
50 assign xa_im = xa[WIDTH/2-1:0];
50 assign xa_im = xa[WIDTH/2-1:0];
51 wire signed [WIDTH/2-1: 0] ya_re;
51 wire signed [WIDTH/2-1: 0] ya_re;
52 wire signed [WIDTH/2-1: 0] ya_im;
52 wire signed [WIDTH/2-1: 0] ya_im;
53 assign ya = {ya_re, ya_im};
53 assign ya = {ya_re, ya_im};
54 wire signed [WIDTH/2-1: 0] yb_re;
54 wire signed [WIDTH/2-1: 0] yb_re;
55 wire signed [WIDTH/2-1: 0] yb_im;
55 wire signed [WIDTH/2-1: 0] yb_im;
56 assign yb = {yb_re, yb_im};
56 assign yb = {yb_re, yb_im};
57
57
58 // Delayed stuff.
58 // Delayed stuff.
59 reg signed [WIDTH/2-1:0] xa_re_z;
59 reg signed [WIDTH/2-1:0] xa_re_z;
60 reg signed [WIDTH/2-1:0] xa_im_z;
60 reg signed [WIDTH/2-1:0] xa_im_z;
61 // Output of multiplier
61 // Output of multiplier
62 wire signed [WIDTH-1:0] xbw;
62 wire signed [WIDTH-1:0] xbw;
63 wire signed [WIDTH/2-1:0] xbw_re;
63 wire signed [WIDTH/2-1:0] xbw_re;
64 wire signed [WIDTH/2-1:0] xbw_im;
64 wire signed [WIDTH/2-1:0] xbw_im;
65 assign xbw_re = xbw[WIDTH-1:WIDTH/2];
65 assign xbw_re = xbw[WIDTH-1:WIDTH/2];
66 assign xbw_im = xbw[WIDTH/2-1:0];
66 assign xbw_im = xbw[WIDTH/2-1:0];
67 // Do summing
67 // Do summing
68 // I don't think we should get overflow here because of the
68 // I don't think we should get overflow here because of the
69 // size of the twiddle factors.
69 // size of the twiddle factors.
70 // If we do testing should catch it.
70 // If we do testing should catch it.
71 assign ya_re = xa_re_z + xbw_re;
71 assign ya_re = xa_re_z + xbw_re;
72 assign ya_im = xa_im_z + xbw_im;
72 assign ya_im = xa_im_z + xbw_im;
73 assign yb_re = xa_re_z - xbw_re;
73 assign yb_re = xa_re_z - xbw_re;
74 assign yb_im = xa_im_z - xbw_im;
74 assign yb_im = xa_im_z - xbw_im;
75
75
76 // Create the multiply module.
76 // Create the multiply module.
77 multiply_complex #(WIDTH) multiply_complex_0
77 multiply_complex #(WIDTH) multiply_complex_0
78 (.clk(clk),
78 (.clk(clk),
79 .rst_n(rst_n),
79 .rst_n(rst_n),
80 .x(xb),
80 .x(xb),
81 .y(w),
81 .y(w),
82 .z(xbw)
82 .z(xbw)
83 );
83 );
84
84
85 always @ (posedge clk)
85 always @ (posedge clk)
86 begin
86 begin
87 if (!rst_n)
87 if (!rst_n)
88 begin
88 begin
89 y_nd <= 1'b0;
89 y_nd <= 1'b0;
90 error <= 1'b0;
90 error <= 1'b0;
91 end
91 end
92 else
92 else
93 begin
93 begin
94 // Set delay for x_nd_old and m.
94 // Set delay for x_nd_old and m.
95 y_nd <= x_nd;
95 y_nd <= x_nd;
96 m_out <= m_in;
96 m_out <= m_in;
97 if (x_nd)
97 if (x_nd)
98 begin
98 begin
99 xa_re_z <= xa_re/2;
99 xa_re_z <= xa_re/2;
100 xa_im_z <= xa_im/2;
100 xa_im_z <= xa_im/2;
101 end
101 end
102 end
102 end
103 end
103 end
104
104
105 endmodule
105 endmodule
106 </textarea></form>
106 </textarea></form>
107
107
108 <script>
108 <script>
109 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
109 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
110 lineNumbers: true,
110 lineNumbers: true,
111 mode: "text/x-verilog"
111 mode: "text/x-verilog"
112 });
112 });
113 </script>
113 </script>
114
114
115 <p>Simple mode that tries to handle Verilog-like languages as well as it
115 <p>Simple mode that tries to handle Verilog-like languages as well as it
116 can. Takes one configuration parameters: <code>keywords</code>, an
116 can. Takes one configuration parameters: <code>keywords</code>, an
117 object whose property names are the keywords in the language.</p>
117 object whose property names are the keywords in the language.</p>
118
118
119 <p><strong>MIME types defined:</strong> <code>text/x-verilog</code> (Verilog code).</p>
119 <p><strong>MIME types defined:</strong> <code>text/x-verilog</code> (Verilog code).</p>
120 </body>
120 </body>
121 </html>
121 </html>
@@ -1,221 +1,221 b''
1 <!doctype html>
1 <!doctype html>
2 <html>
2 <html>
3 <!--
3 <!--
4 /*
4 /*
5 Copyright (C) 2011 by MarkLogic Corporation
5 Copyright (C) 2011 by MarkLogic Corporation
6 Author: Mike Brevoort <mike@brevoort.com>
6 Author: Mike Brevoort <mike@brevoort.com>
7
7
8 Permission is hereby granted, free of charge, to any person obtaining a copy
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
13 furnished to do so, subject to the following conditions:
14
14
15 The above copyright notice and this permission notice shall be included in
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
16 all copies or substantial portions of the Software.
17
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 THE SOFTWARE.
24 THE SOFTWARE.
25 */
25 */
26 -->
26 -->
27 <head>
27 <head>
28 <meta charset="utf-8">
28 <meta charset="utf-8">
29 <title>CodeMirror: XQuery mode</title>
29 <title>CodeMirror: XQuery mode</title>
30 <link rel="stylesheet" href="../../lib/codemirror.css">
30 <link rel="stylesheet" href="../../lib/codemirror.css">
31 <script src="../../lib/codemirror.js"></script>
31 <script src="../../lib/codemirror.js"></script>
32 <script src="xquery.js"></script>
32 <script src="xquery.js"></script>
33 <link rel="stylesheet" href="../../doc/docs.css">
33 <link rel="stylesheet" href="../../doc/docs.css">
34 <link rel="stylesheet" href="../../theme/xq-dark.css">
34 <link rel="stylesheet" href="../../theme/xq-dark.css">
35 <style type="text/css">
35 <style type="text/css">
36 .CodeMirror {
36 .CodeMirror {
37 border-top: 1px solid black; border-bottom: 1px solid black;
37 border-top: 1px solid black; border-bottom: 1px solid black;
38 height:400px;
38 height:400px;
39 }
39 }
40 </style>
40 </style>
41 </head>
41 </head>
42 <body>
42 <body>
43 <h1>CodeMirror: XQuery mode</h1>
43 <h1>CodeMirror: XQuery mode</h1>
44
44
45 <div class="cm-s-default">
45 <div class="cm-s-default">
46 <textarea id="code" name="code">
46 <textarea id="code" name="code">
47 xquery version &quot;1.0-ml&quot;;
47 xquery version &quot;1.0-ml&quot;;
48 (: this is
48 (: this is
49 : a
49 : a
50 "comment" :)
50 "comment" :)
51 let $let := &lt;x attr=&quot;value&quot;&gt;&quot;test&quot;&lt;func&gt;function() $var {function()} {$var}&lt;/func&gt;&lt;/x&gt;
51 let $let := &lt;x attr=&quot;value&quot;&gt;&quot;test&quot;&lt;func&gt;function() $var {function()} {$var}&lt;/func&gt;&lt;/x&gt;
52 let $joe:=1
52 let $joe:=1
53 return element element {
53 return element element {
54 attribute attribute { 1 },
54 attribute attribute { 1 },
55 element test { &#39;a&#39; },
55 element test { &#39;a&#39; },
56 attribute foo { &quot;bar&quot; },
56 attribute foo { &quot;bar&quot; },
57 fn:doc()[ foo/@bar eq $let ],
57 fn:doc()[ foo/@bar eq $let ],
58 //x }
58 //x }
59
59
60 (: a more 'evil' test :)
60 (: a more 'evil' test :)
61 (: Modified Blakeley example (: with nested comment :) ... :)
61 (: Modified Blakeley example (: with nested comment :) ... :)
62 declare private function local:declare() {()};
62 declare private function local:declare() {()};
63 declare private function local:private() {()};
63 declare private function local:private() {()};
64 declare private function local:function() {()};
64 declare private function local:function() {()};
65 declare private function local:local() {()};
65 declare private function local:local() {()};
66 let $let := &lt;let&gt;let $let := &quot;let&quot;&lt;/let&gt;
66 let $let := &lt;let&gt;let $let := &quot;let&quot;&lt;/let&gt;
67 return element element {
67 return element element {
68 attribute attribute { try { xdmp:version() } catch($e) { xdmp:log($e) } },
68 attribute attribute { try { xdmp:version() } catch($e) { xdmp:log($e) } },
69 attribute fn:doc { &quot;bar&quot; castable as xs:string },
69 attribute fn:doc { &quot;bar&quot; castable as xs:string },
70 element text { text { &quot;text&quot; } },
70 element text { text { &quot;text&quot; } },
71 fn:doc()[ child::eq/(@bar | attribute::attribute) eq $let ],
71 fn:doc()[ child::eq/(@bar | attribute::attribute) eq $let ],
72 //fn:doc
72 //fn:doc
73 }
73 }
74
74
75
75
76
76
77 xquery version &quot;1.0-ml&quot;;
77 xquery version &quot;1.0-ml&quot;;
78
78
79 (: Copyright 2006-2010 Mark Logic Corporation. :)
79 (: Copyright 2006-2010 Mark Logic Corporation. :)
80
80
81 (:
81 (:
82 : Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
82 : Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
83 : you may not use this file except in compliance with the License.
83 : you may not use this file except in compliance with the License.
84 : You may obtain a copy of the License at
84 : You may obtain a copy of the License at
85 :
85 :
86 : http://www.apache.org/licenses/LICENSE-2.0
86 : http://www.apache.org/licenses/LICENSE-2.0
87 :
87 :
88 : Unless required by applicable law or agreed to in writing, software
88 : Unless required by applicable law or agreed to in writing, software
89 : distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
89 : distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
90 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
90 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
91 : See the License for the specific language governing permissions and
91 : See the License for the specific language governing permissions and
92 : limitations under the License.
92 : limitations under the License.
93 :)
93 :)
94
94
95 module namespace json = &quot;http://marklogic.com/json&quot;;
95 module namespace json = &quot;http://marklogic.com/json&quot;;
96 declare default function namespace &quot;http://www.w3.org/2005/xpath-functions&quot;;
96 declare default function namespace &quot;http://www.w3.org/2005/xpath-functions&quot;;
97
97
98 (: Need to backslash escape any double quotes, backslashes, and newlines :)
98 (: Need to backslash escape any double quotes, backslashes, and newlines :)
99 declare function json:escape($s as xs:string) as xs:string {
99 declare function json:escape($s as xs:string) as xs:string {
100 let $s := replace($s, &quot;\\&quot;, &quot;\\\\&quot;)
100 let $s := replace($s, &quot;\\&quot;, &quot;\\\\&quot;)
101 let $s := replace($s, &quot;&quot;&quot;&quot;, &quot;\\&quot;&quot;&quot;)
101 let $s := replace($s, &quot;&quot;&quot;&quot;, &quot;\\&quot;&quot;&quot;)
102 let $s := replace($s, codepoints-to-string((13, 10)), &quot;\\n&quot;)
102 let $s := replace($s, codepoints-to-string((13, 10)), &quot;\\n&quot;)
103 let $s := replace($s, codepoints-to-string(13), &quot;\\n&quot;)
103 let $s := replace($s, codepoints-to-string(13), &quot;\\n&quot;)
104 let $s := replace($s, codepoints-to-string(10), &quot;\\n&quot;)
104 let $s := replace($s, codepoints-to-string(10), &quot;\\n&quot;)
105 return $s
105 return $s
106 };
106 };
107
107
108 declare function json:atomize($x as element()) as xs:string {
108 declare function json:atomize($x as element()) as xs:string {
109 if (count($x/node()) = 0) then 'null'
109 if (count($x/node()) = 0) then 'null'
110 else if ($x/@type = &quot;number&quot;) then
110 else if ($x/@type = &quot;number&quot;) then
111 let $castable := $x castable as xs:float or
111 let $castable := $x castable as xs:float or
112 $x castable as xs:double or
112 $x castable as xs:double or
113 $x castable as xs:decimal
113 $x castable as xs:decimal
114 return
114 return
115 if ($castable) then xs:string($x)
115 if ($castable) then xs:string($x)
116 else error(concat(&quot;Not a number: &quot;, xdmp:describe($x)))
116 else error(concat(&quot;Not a number: &quot;, xdmp:describe($x)))
117 else if ($x/@type = &quot;boolean&quot;) then
117 else if ($x/@type = &quot;boolean&quot;) then
118 let $castable := $x castable as xs:boolean
118 let $castable := $x castable as xs:boolean
119 return
119 return
120 if ($castable) then xs:string(xs:boolean($x))
120 if ($castable) then xs:string(xs:boolean($x))
121 else error(concat(&quot;Not a boolean: &quot;, xdmp:describe($x)))
121 else error(concat(&quot;Not a boolean: &quot;, xdmp:describe($x)))
122 else concat('&quot;', json:escape($x), '&quot;')
122 else concat('&quot;', json:escape($x), '&quot;')
123 };
123 };
124
124
125 (: Print the thing that comes after the colon :)
125 (: Print the thing that comes after the colon :)
126 declare function json:print-value($x as element()) as xs:string {
126 declare function json:print-value($x as element()) as xs:string {
127 if (count($x/*) = 0) then
127 if (count($x/*) = 0) then
128 json:atomize($x)
128 json:atomize($x)
129 else if ($x/@quote = &quot;true&quot;) then
129 else if ($x/@quote = &quot;true&quot;) then
130 concat('&quot;', json:escape(xdmp:quote($x/node())), '&quot;')
130 concat('&quot;', json:escape(xdmp:quote($x/node())), '&quot;')
131 else
131 else
132 string-join(('{',
132 string-join(('{',
133 string-join(for $i in $x/* return json:print-name-value($i), &quot;,&quot;),
133 string-join(for $i in $x/* return json:print-name-value($i), &quot;,&quot;),
134 '}'), &quot;&quot;)
134 '}'), &quot;&quot;)
135 };
135 };
136
136
137 (: Print the name and value both :)
137 (: Print the name and value both :)
138 declare function json:print-name-value($x as element()) as xs:string? {
138 declare function json:print-name-value($x as element()) as xs:string? {
139 let $name := name($x)
139 let $name := name($x)
140 let $first-in-array :=
140 let $first-in-array :=
141 count($x/preceding-sibling::*[name(.) = $name]) = 0 and
141 count($x/preceding-sibling::*[name(.) = $name]) = 0 and
142 (count($x/following-sibling::*[name(.) = $name]) &gt; 0 or $x/@array = &quot;true&quot;)
142 (count($x/following-sibling::*[name(.) = $name]) &gt; 0 or $x/@array = &quot;true&quot;)
143 let $later-in-array := count($x/preceding-sibling::*[name(.) = $name]) &gt; 0
143 let $later-in-array := count($x/preceding-sibling::*[name(.) = $name]) &gt; 0
144 return
144 return
145
145
146 if ($later-in-array) then
146 if ($later-in-array) then
147 () (: I was handled previously :)
147 () (: I was handled previously :)
148 else if ($first-in-array) then
148 else if ($first-in-array) then
149 string-join(('&quot;', json:escape($name), '&quot;:[',
149 string-join(('&quot;', json:escape($name), '&quot;:[',
150 string-join((for $i in ($x, $x/following-sibling::*[name(.) = $name]) return json:print-value($i)), &quot;,&quot;),
150 string-join((for $i in ($x, $x/following-sibling::*[name(.) = $name]) return json:print-value($i)), &quot;,&quot;),
151 ']'), &quot;&quot;)
151 ']'), &quot;&quot;)
152 else
152 else
153 string-join(('&quot;', json:escape($name), '&quot;:', json:print-value($x)), &quot;&quot;)
153 string-join(('&quot;', json:escape($name), '&quot;:', json:print-value($x)), &quot;&quot;)
154 };
154 };
155
155
156 (:~
156 (:~
157 Transforms an XML element into a JSON string representation. See http://json.org.
157 Transforms an XML element into a JSON string representation. See http://json.org.
158 &lt;p/&gt;
158 &lt;p/&gt;
159 Sample usage:
159 Sample usage:
160 &lt;pre&gt;
160 &lt;pre&gt;
161 xquery version &quot;1.0-ml&quot;;
161 xquery version &quot;1.0-ml&quot;;
162 import module namespace json=&quot;http://marklogic.com/json&quot; at &quot;json.xqy&quot;;
162 import module namespace json=&quot;http://marklogic.com/json&quot; at &quot;json.xqy&quot;;
163 json:serialize(&amp;lt;foo&amp;gt;&amp;lt;bar&amp;gt;kid&amp;lt;/bar&amp;gt;&amp;lt;/foo&amp;gt;)
163 json:serialize(&amp;lt;foo&amp;gt;&amp;lt;bar&amp;gt;kid&amp;lt;/bar&amp;gt;&amp;lt;/foo&amp;gt;)
164 &lt;/pre&gt;
164 &lt;/pre&gt;
165 Sample transformations:
165 Sample transformations:
166 &lt;pre&gt;
166 &lt;pre&gt;
167 &amp;lt;e/&amp;gt; becomes {&quot;e&quot;:null}
167 &amp;lt;e/&amp;gt; becomes {&quot;e&quot;:null}
168 &amp;lt;e&amp;gt;text&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:&quot;text&quot;}
168 &amp;lt;e&amp;gt;text&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:&quot;text&quot;}
169 &amp;lt;e&amp;gt;quote &quot; escaping&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:&quot;quote \&quot; escaping&quot;}
169 &amp;lt;e&amp;gt;quote &quot; escaping&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:&quot;quote \&quot; escaping&quot;}
170 &amp;lt;e&amp;gt;backslash \ escaping&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:&quot;backslash \\ escaping&quot;}
170 &amp;lt;e&amp;gt;backslash \ escaping&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:&quot;backslash \\ escaping&quot;}
171 &amp;lt;e&amp;gt;&amp;lt;a&amp;gt;text1&amp;lt;/a&amp;gt;&amp;lt;b&amp;gt;text2&amp;lt;/b&amp;gt;&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:{&quot;a&quot;:&quot;text1&quot;,&quot;b&quot;:&quot;text2&quot;}}
171 &amp;lt;e&amp;gt;&amp;lt;a&amp;gt;text1&amp;lt;/a&amp;gt;&amp;lt;b&amp;gt;text2&amp;lt;/b&amp;gt;&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:{&quot;a&quot;:&quot;text1&quot;,&quot;b&quot;:&quot;text2&quot;}}
172 &amp;lt;e&amp;gt;&amp;lt;a&amp;gt;text1&amp;lt;/a&amp;gt;&amp;lt;a&amp;gt;text2&amp;lt;/a&amp;gt;&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:{&quot;a&quot;:[&quot;text1&quot;,&quot;text2&quot;]}}
172 &amp;lt;e&amp;gt;&amp;lt;a&amp;gt;text1&amp;lt;/a&amp;gt;&amp;lt;a&amp;gt;text2&amp;lt;/a&amp;gt;&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:{&quot;a&quot;:[&quot;text1&quot;,&quot;text2&quot;]}}
173 &amp;lt;e&amp;gt;&amp;lt;a array=&quot;true&quot;&amp;gt;text1&amp;lt;/a&amp;gt;&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:{&quot;a&quot;:[&quot;text1&quot;]}}
173 &amp;lt;e&amp;gt;&amp;lt;a array=&quot;true&quot;&amp;gt;text1&amp;lt;/a&amp;gt;&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:{&quot;a&quot;:[&quot;text1&quot;]}}
174 &amp;lt;e&amp;gt;&amp;lt;a type=&quot;boolean&quot;&amp;gt;false&amp;lt;/a&amp;gt;&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:{&quot;a&quot;:false}}
174 &amp;lt;e&amp;gt;&amp;lt;a type=&quot;boolean&quot;&amp;gt;false&amp;lt;/a&amp;gt;&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:{&quot;a&quot;:false}}
175 &amp;lt;e&amp;gt;&amp;lt;a type=&quot;number&quot;&amp;gt;123.5&amp;lt;/a&amp;gt;&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:{&quot;a&quot;:123.5}}
175 &amp;lt;e&amp;gt;&amp;lt;a type=&quot;number&quot;&amp;gt;123.5&amp;lt;/a&amp;gt;&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:{&quot;a&quot;:123.5}}
176 &amp;lt;e quote=&quot;true&quot;&amp;gt;&amp;lt;div attrib=&quot;value&quot;/&amp;gt;&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:&quot;&amp;lt;div attrib=\&quot;value\&quot;/&amp;gt;&quot;}
176 &amp;lt;e quote=&quot;true&quot;&amp;gt;&amp;lt;div attrib=&quot;value&quot;/&amp;gt;&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:&quot;&amp;lt;div attrib=\&quot;value\&quot;/&amp;gt;&quot;}
177 &lt;/pre&gt;
177 &lt;/pre&gt;
178 &lt;p/&gt;
178 &lt;p/&gt;
179 Namespace URIs are ignored. Namespace prefixes are included in the JSON name.
179 Namespace URIs are ignored. Namespace prefixes are included in the JSON name.
180 &lt;p/&gt;
180 &lt;p/&gt;
181 Attributes are ignored, except for the special attribute @array=&quot;true&quot; that
181 Attributes are ignored, except for the special attribute @array=&quot;true&quot; that
182 indicates the JSON serialization should write the node, even if single, as an
182 indicates the JSON serialization should write the node, even if single, as an
183 array, and the attribute @type that can be set to &quot;boolean&quot; or &quot;number&quot; to
183 array, and the attribute @type that can be set to &quot;boolean&quot; or &quot;number&quot; to
184 dictate the value should be written as that type (unquoted). There's also
184 dictate the value should be written as that type (unquoted). There's also
185 an @quote attribute that when set to true writes the inner content as text
185 an @quote attribute that when set to true writes the inner content as text
186 rather than as structured JSON, useful for sending some XHTML over the
186 rather than as structured JSON, useful for sending some XHTML over the
187 wire.
187 wire.
188 &lt;p/&gt;
188 &lt;p/&gt;
189 Text nodes within mixed content are ignored.
189 Text nodes within mixed content are ignored.
190
190
191 @param $x Element node to convert
191 @param $x Element node to convert
192 @return String holding JSON serialized representation of $x
192 @return String holding JSON serialized representation of $x
193
193
194 @author Jason Hunter
194 @author Jason Hunter
195 @version 1.0.1
195 @version 1.0.1
196
196
197 Ported to xquery 1.0-ml; double escaped backslashes in json:escape
197 Ported to xquery 1.0-ml; double escaped backslashes in json:escape
198 :)
198 :)
199 declare function json:serialize($x as element()) as xs:string {
199 declare function json:serialize($x as element()) as xs:string {
200 string-join(('{', json:print-name-value($x), '}'), &quot;&quot;)
200 string-join(('{', json:print-name-value($x), '}'), &quot;&quot;)
201 };
201 };
202 </textarea>
202 </textarea>
203 </div>
203 </div>
204
204
205 <script>
205 <script>
206 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
206 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
207 lineNumbers: true,
207 lineNumbers: true,
208 matchBrackets: true,
208 matchBrackets: true,
209 theme: "xq-dark"
209 theme: "xq-dark"
210 });
210 });
211 </script>
211 </script>
212
212
213 <p><strong>MIME types defined:</strong> <code>application/xquery</code>.</p>
213 <p><strong>MIME types defined:</strong> <code>application/xquery</code>.</p>
214
214
215 <p>Development of the CodeMirror XQuery mode was sponsored by
215 <p>Development of the CodeMirror XQuery mode was sponsored by
216 <a href="http://marklogic.com">MarkLogic</a> and developed by
216 <a href="http://marklogic.com">MarkLogic</a> and developed by
217 <a href="https://twitter.com/mbrevoort">Mike Brevoort</a>.
217 <a href="https://twitter.com/mbrevoort">Mike Brevoort</a>.
218 </p>
218 </p>
219
219
220 </body>
220 </body>
221 </html>
221 </html>
General Comments 0
You need to be logged in to leave comments. Login now