##// END OF EJS Templates
codecleaner
marcink -
r4029:c9bcfe2d default
parent child Browse files
Show More
@@ -1,61 +1,61 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: APL mode</title>
6 <link rel="stylesheet" href="../../doc/docs.css">
7 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <link rel="stylesheet" href="../../doc/docs.css">
7 <link rel="stylesheet" href="../../lib/codemirror.css">
8 8 <script src="../../lib/codemirror.js"></script>
9 9 <script src="../../addon/edit/matchbrackets.js"></script>
10 10 <script src="apl.js"></script>
11 11 <style>
12 .CodeMirror { border: 2px inset #dee; }
12 .CodeMirror { border: 2px inset #dee; }
13 13 </style>
14 14 </head>
15 15 <body>
16 16 <h1>CodeMirror: APL mode</h1>
17 17
18 18 <form><textarea id="code" name="code">
19 19 ⍝ Conway's game of life
20 20
21 21 ⍝ This example was inspired by the impressive demo at
22 22 ⍝ http://www.youtube.com/watch?v=a9xAKttWgP4
23 23
24 24 ⍝ Create a matrix:
25 25 ⍝ 0 1 1
26 26 ⍝ 1 1 0
27 27 ⍝ 0 1 0
28 28 creature ← (3 3 ⍴ ⍳ 9) ∈ 1 2 3 4 7 ⍝ Original creature from demo
29 29 creature ← (3 3 ⍴ ⍳ 9) ∈ 1 3 6 7 8 ⍝ Glider
30 30
31 31 ⍝ Place the creature on a larger board, near the centre
32 32 board ← ¯1 ⊖ ¯2 ⌽ 5 7 ↑ creature
33 33
34 34 ⍝ A function to move from one generation to the next
35 35 life ← {∨/ 1 ⍵ ∧ 3 4 = ⊂+/ +⌿ 1 0 ¯1 ∘.⊖ 1 0 ¯1 ⌽¨ ⊂⍵}
36 36
37 37 ⍝ Compute n-th generation and format it as a
38 38 ⍝ character matrix
39 39 gen ← {' #'[(life ⍣ ⍵) board]}
40 40
41 41 ⍝ Show first three generations
42 42 (gen 1) (gen 2) (gen 3)
43 43 </textarea></form>
44 44
45 45 <script>
46 46 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
47 47 lineNumbers: true,
48 48 matchBrackets: true,
49 49 mode: "text/apl"
50 50 });
51 51 </script>
52 52
53 53 <p>Simple mode that tries to handle APL as well as it can.</p>
54 54 <p>It attempts to label functions/operators based upon
55 55 monadic/dyadic usage (but this is far from fully fleshed out).
56 56 This means there are meaningful classnames so hover states can
57 57 have popups etc.</p>
58 58
59 59 <p><strong>MIME types defined:</strong> <code>text/apl</code> (APL code)</p>
60 60 </body>
61 61 </html>
@@ -1,142 +1,142 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: Asterisk dialplan mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="asterisk.js"></script>
9 9 <style>
10 10 .CodeMirror {border: 1px solid #999;}
11 11 .cm-s-default span.cm-arrow { color: red; }
12 12 </style>
13 13 <link rel="stylesheet" href="../../doc/docs.css">
14 14 </head>
15 15 <body>
16 16 <h1>CodeMirror: Asterisk dialplan mode</h1>
17 17 <form><textarea id="code" name="code">
18 18 ; extensions.conf - the Asterisk dial plan
19 19 ;
20 20
21 21 [general]
22 22 ;
23 23 ; If static is set to no, or omitted, then the pbx_config will rewrite
24 24 ; this file when extensions are modified. Remember that all comments
25 25 ; made in the file will be lost when that happens.
26 26 static=yes
27 27
28 28 #include "/etc/asterisk/additional_general.conf
29 29
30 30 [iaxprovider]
31 31 switch => IAX2/user:[key]@myserver/mycontext
32 32
33 33 [dynamic]
34 34 #exec /usr/bin/dynamic-peers.pl
35 35
36 36 [trunkint]
37 37 ;
38 38 ; International long distance through trunk
39 39 ;
40 40 exten => _9011.,1,Macro(dundi-e164,${EXTEN:4})
41 41 exten => _9011.,n,Dial(${GLOBAL(TRUNK)}/${FILTER(0-9,${EXTEN:${GLOBAL(TRUNKMSD)}})})
42 42
43 43 [local]
44 44 ;
45 45 ; Master context for local, toll-free, and iaxtel calls only
46 46 ;
47 47 ignorepat => 9
48 48 include => default
49 49
50 50 [demo]
51 51 include => stdexten
52 52 ;
53 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
56 same => n,Answer ; Answer the line
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
59 same => n(restart),BackGround(demo-congrats) ; Play a congratulatory message
60 same => n(instruct),BackGround(demo-instruct) ; Play some instructions
61 same => n,WaitExten ; Wait for an extension to be dialed.
55 exten => s,1,Wait(1) ; Wait a second, just for fun
56 same => n,Answer ; Answer the line
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
59 same => n(restart),BackGround(demo-congrats) ; Play a congratulatory message
60 same => n(instruct),BackGround(demo-instruct) ; Play some instructions
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 64 exten => 2,n,Goto(s,instruct)
65 65
66 exten => 3,1,Set(LANGUAGE()=fr) ; Set language to french
67 exten => 3,n,Goto(s,restart) ; Start with the congratulations
66 exten => 3,1,Set(LANGUAGE()=fr) ; Set language to french
67 exten => 3,n,Goto(s,restart) ; Start with the congratulations
68 68
69 69 exten => 1000,1,Goto(default,s,1)
70 70 ;
71 71 ; We also create an example user, 1234, who is on the console and has
72 72 ; voicemail, etc.
73 73 ;
74 exten => 1234,1,Playback(transfer,skip) ; "Please hold while..."
75 ; (but skip if channel is not up)
74 exten => 1234,1,Playback(transfer,skip) ; "Please hold while..."
75 ; (but skip if channel is not up)
76 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
82 exten => 1236,n,Voicemail(1234,b) ; Unless busy
81 exten => 1236,1,Dial(Console/dsp) ; Ring forever
82 exten => 1236,n,Voicemail(1234,b) ; Unless busy
83 83
84 84 ;
85 85 ; # for when they're done with the demo
86 86 ;
87 exten => #,1,Playback(demo-thanks) ; "Thanks for trying the demo"
88 exten => #,n,Hangup ; Hang them up.
87 exten => #,1,Playback(demo-thanks) ; "Thanks for trying the demo"
88 exten => #,n,Hangup ; Hang them up.
89 89
90 90 ;
91 91 ; A timeout and "invalid extension rule"
92 92 ;
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"
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"
95 95
96 96 ;
97 97 ; Create an extension, 500, for dialing the
98 98 ; Asterisk demo.
99 99 ;
100 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
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.
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
103 exten => 500,n,Goto(s,6) ; Return to the start over message.
104 104
105 105 ;
106 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
109 exten => 600,n,Echo ; Do the echo test
110 exten => 600,n,Playback(demo-echodone) ; Let them know it's over
111 exten => 600,n,Goto(s,6) ; Start over
108 exten => 600,1,Playback(demo-echotest) ; Let them know what's going on
109 exten => 600,n,Echo ; Do the echo test
110 exten => 600,n,Playback(demo-echodone) ; Let them know it's 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 115 exten => 76245,1,Macro(page,SIP/Grandstream1)
116 116 ; or if your peernames are the same as extensions
117 117 exten => _7XXX,1,Macro(page,SIP/${EXTEN})
118 118 ;
119 119 ;
120 120 ; System Wide Page at extension 7999
121 121 ;
122 122 exten => 7999,1,Set(TIMEOUT(absolute)=60)
123 123 exten => 7999,2,Page(Local/Grandstream1@page&Local/Xlite1@page&Local/1234@page/n,d)
124 124
125 125 ; Give voicemail at extension 8500
126 126 ;
127 127 exten => 8500,1,VoicemailMain
128 128 exten => 8500,n,Goto(s,6)
129 129
130 130 </textarea></form>
131 131 <script>
132 132 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
133 133 mode: "text/x-asterisk",
134 134 matchBrackets: true,
135 135 lineNumber: true
136 136 });
137 137 </script>
138 138
139 139 <p><strong>MIME types defined:</strong> <code>text/x-asterisk</code>.</p>
140 140
141 141 </body>
142 142 </html>
@@ -1,767 +1,767 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: C-like mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <link rel="stylesheet" href="../../theme/ambiance.css">
8 8 <script src="../../lib/codemirror.js"></script>
9 9 <script src="../../addon/edit/matchbrackets.js"></script>
10 10 <script src="clike.js"></script>
11 11 <link rel="stylesheet" href="../../doc/docs.css">
12 12 <style>
13 13 body
14 14 {
15 15 margin: 0;
16 16 padding: 0;
17 17 max-width:inherit;
18 18 height: 100%;
19 19 }
20 20 html, form, .CodeMirror, .CodeMirror-scroll
21 21 {
22 height: 100%;
22 height: 100%;
23 23 }
24 24 </style>
25 25 </head>
26 26 <body>
27 27 <form>
28 28 <textarea id="code" name="code">
29 29
30 30 /* __ *\
31 31 ** ________ ___ / / ___ Scala API **
32 32 ** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL **
33 33 ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
34 34 ** /____/\___/_/ |_/____/_/ | | **
35 35 ** |/ **
36 36 \* */
37 37
38 38 package scala.collection
39 39
40 40 import generic._
41 41 import mutable.{ Builder, ListBuffer }
42 42 import annotation.{tailrec, migration, bridge}
43 43 import annotation.unchecked.{ uncheckedVariance => uV }
44 44 import parallel.ParIterable
45 45
46 46 /** A template trait for traversable collections of type `Traversable[A]`.
47 *
47 *
48 48 * $traversableInfo
49 49 * @define mutability
50 50 * @define traversableInfo
51 51 * This is a base trait of all kinds of $mutability Scala collections. It
52 52 * implements the behavior common to all collections, in terms of a method
53 53 * `foreach` with signature:
54 54 * {{{
55 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 58 * `foreach` method which traverses all the
59 59 * elements contained in the collection, applying a given function to each.
60 60 * They also need to provide a method `newBuilder`
61 61 * which creates a builder for collections of the same kind.
62 *
62 *
63 63 * A traversable class might or might not have two properties: strictness
64 64 * and orderedness. Neither is represented as a type.
65 *
65 *
66 66 * The instances of a strict collection class have all their elements
67 67 * computed before they can be used as values. By contrast, instances of
68 68 * a non-strict collection class may defer computation of some of their
69 69 * elements until after the instance is available as a value.
70 70 * A typical example of a non-strict collection class is a
71 71 * <a href="../immutable/Stream.html" target="ContentFrame">
72 72 * `scala.collection.immutable.Stream`</a>.
73 73 * A more general class of examples are `TraversableViews`.
74 *
74 *
75 75 * If a collection is an instance of an ordered collection class, traversing
76 76 * its elements with `foreach` will always visit elements in the
77 77 * same order, even for different runs of the program. If the class is not
78 78 * ordered, `foreach` can visit elements in different orders for
79 79 * different runs (but it will keep the same order in the same run).'
80 *
80 *
81 81 * A typical example of a collection class which is not ordered is a
82 82 * `HashMap` of objects. The traversal order for hash maps will
83 83 * depend on the hash codes of its elements, and these hash codes might
84 84 * differ from one run to the next. By contrast, a `LinkedHashMap`
85 85 * is ordered because it's `foreach` method visits elements in the
86 86 * order they were inserted into the `HashMap`.
87 87 *
88 88 * @author Martin Odersky
89 89 * @version 2.8
90 90 * @since 2.8
91 91 * @tparam A the element type of the collection
92 92 * @tparam Repr the type of the actual collection containing the elements.
93 93 *
94 94 * @define Coll Traversable
95 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 98 with FilterMonadic[A, Repr]
99 99 with TraversableOnce[A]
100 100 with GenTraversableLike[A, Repr]
101 101 with Parallelizable[A, ParIterable[A]]
102 102 {
103 103 self =>
104 104
105 105 import Traversable.breaks._
106 106
107 107 /** The type implementing this traversable */
108 108 protected type Self = Repr
109 109
110 110 /** The collection of type $coll underlying this `TraversableLike` object.
111 111 * By default this is implemented as the `TraversableLike` object itself,
112 112 * but this can be overridden.
113 113 */
114 114 def repr: Repr = this.asInstanceOf[Repr]
115 115
116 116 /** The underlying collection seen as an instance of `$Coll`.
117 117 * By default this is implemented as the current collection object itself,
118 118 * but this can be overridden.
119 119 */
120 120 protected[this] def thisCollection: Traversable[A] = this.asInstanceOf[Traversable[A]]
121 121
122 122 /** A conversion from collections of type `Repr` to `$Coll` objects.
123 123 * By default this is implemented as just a cast, but this can be overridden.
124 124 */
125 125 protected[this] def toCollection(repr: Repr): Traversable[A] = repr.asInstanceOf[Traversable[A]]
126 126
127 127 /** Creates a new builder for this collection type.
128 128 */
129 129 protected[this] def newBuilder: Builder[A, Repr]
130 130
131 131 protected[this] def parCombiner = ParIterable.newCombiner[A]
132 132
133 133 /** Applies a function `f` to all elements of this $coll.
134 *
134 *
135 135 * Note: this method underlies the implementation of most other bulk operations.
136 136 * It's important to implement this method in an efficient way.
137 *
137 *
138 138 *
139 139 * @param f the function that is applied for its side-effect to every element.
140 140 * The result of function `f` is discarded.
141 *
142 * @tparam U the type parameter describing the result of function `f`.
141 *
142 * @tparam U the type parameter describing the result of function `f`.
143 143 * This result will always be ignored. Typically `U` is `Unit`,
144 144 * but this is not necessary.
145 145 *
146 146 * @usecase def foreach(f: A => Unit): Unit
147 147 */
148 148 def foreach[U](f: A => U): Unit
149 149
150 150 /** Tests whether this $coll is empty.
151 151 *
152 152 * @return `true` if the $coll contain no elements, `false` otherwise.
153 153 */
154 154 def isEmpty: Boolean = {
155 155 var result = true
156 156 breakable {
157 157 for (x <- this) {
158 158 result = false
159 159 break
160 160 }
161 161 }
162 162 result
163 163 }
164 164
165 165 /** Tests whether this $coll is known to have a finite size.
166 166 * All strict collections are known to have finite size. For a non-strict collection
167 167 * such as `Stream`, the predicate returns `true` if all elements have been computed.
168 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 172 * @return `true` if this collection is known to have finite size, `false` otherwise.
173 173 */
174 174 def hasDefiniteSize = true
175 175
176 176 def ++[B >: A, That](that: GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
177 177 val b = bf(repr)
178 178 if (that.isInstanceOf[IndexedSeqLike[_, _]]) b.sizeHint(this, that.seq.size)
179 179 b ++= thisCollection
180 180 b ++= that.seq
181 181 b.result
182 182 }
183 183
184 184 @bridge
185 185 def ++[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That =
186 186 ++(that: GenTraversableOnce[B])(bf)
187 187
188 188 /** Concatenates this $coll with the elements of a traversable collection.
189 189 * It differs from ++ in that the right operand determines the type of the
190 190 * resulting collection rather than the left one.
191 *
191 *
192 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 194 * @tparam That $thatinfo
195 195 * @param bf $bfinfo
196 196 * @return a new collection of type `That` which contains all elements
197 197 * of this $coll followed by all elements of `that`.
198 *
198 *
199 199 * @usecase def ++:[B](that: TraversableOnce[B]): $Coll[B]
200 *
200 *
201 201 * @return a new $coll which contains all elements of this $coll
202 202 * followed by all elements of `that`.
203 203 */
204 204 def ++:[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
205 205 val b = bf(repr)
206 206 if (that.isInstanceOf[IndexedSeqLike[_, _]]) b.sizeHint(this, that.size)
207 207 b ++= that
208 208 b ++= thisCollection
209 209 b.result
210 210 }
211 211
212 212 /** This overload exists because: for the implementation of ++: we should reuse
213 213 * that of ++ because many collections override it with more efficient versions.
214 214 * Since TraversableOnce has no '++' method, we have to implement that directly,
215 215 * but Traversable and down can use the overload.
216 216 */
217 217 def ++:[B >: A, That](that: Traversable[B])(implicit bf: CanBuildFrom[Repr, B, That]): That =
218 218 (that ++ seq)(breakOut)
219 219
220 220 def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
221 221 val b = bf(repr)
222 b.sizeHint(this)
222 b.sizeHint(this)
223 223 for (x <- this) b += f(x)
224 224 b.result
225 225 }
226 226
227 227 def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
228 228 val b = bf(repr)
229 229 for (x <- this) b ++= f(x).seq
230 230 b.result
231 231 }
232 232
233 233 /** Selects all elements of this $coll which satisfy a predicate.
234 234 *
235 235 * @param p the predicate used to test elements.
236 236 * @return a new $coll consisting of all elements of this $coll that satisfy the given
237 237 * predicate `p`. The order of the elements is preserved.
238 238 */
239 239 def filter(p: A => Boolean): Repr = {
240 240 val b = newBuilder
241 for (x <- this)
241 for (x <- this)
242 242 if (p(x)) b += x
243 243 b.result
244 244 }
245 245
246 246 /** Selects all elements of this $coll which do not satisfy a predicate.
247 247 *
248 248 * @param p the predicate used to test elements.
249 249 * @return a new $coll consisting of all elements of this $coll that do not satisfy the given
250 250 * predicate `p`. The order of the elements is preserved.
251 251 */
252 252 def filterNot(p: A => Boolean): Repr = filter(!p(_))
253 253
254 254 def collect[B, That](pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
255 255 val b = bf(repr)
256 256 for (x <- this) if (pf.isDefinedAt(x)) b += pf(x)
257 257 b.result
258 258 }
259 259
260 260 /** Builds a new collection by applying an option-valued function to all
261 261 * elements of this $coll on which the function is defined.
262 262 *
263 263 * @param f the option-valued function which filters and maps the $coll.
264 264 * @tparam B the element type of the returned collection.
265 265 * @tparam That $thatinfo
266 266 * @param bf $bfinfo
267 267 * @return a new collection of type `That` resulting from applying the option-valued function
268 268 * `f` to each element and collecting all defined results.
269 269 * The order of the elements is preserved.
270 270 *
271 271 * @usecase def filterMap[B](f: A => Option[B]): $Coll[B]
272 *
272 *
273 273 * @param pf the partial function which filters and maps the $coll.
274 274 * @return a new $coll resulting from applying the given option-valued function
275 275 * `f` to each element and collecting all defined results.
276 276 * The order of the elements is preserved.
277 277 def filterMap[B, That](f: A => Option[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
278 278 val b = bf(repr)
279 for (x <- this)
279 for (x <- this)
280 280 f(x) match {
281 281 case Some(y) => b += y
282 282 case _ =>
283 283 }
284 284 b.result
285 285 }
286 286 */
287 287
288 288 /** Partitions this $coll in two ${coll}s according to a predicate.
289 289 *
290 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 292 * satisfy the predicate `p` and the second $coll consists of all elements
293 293 * that don't. The relative order of the elements in the resulting ${coll}s
294 294 * is the same as in the original $coll.
295 295 */
296 296 def partition(p: A => Boolean): (Repr, Repr) = {
297 297 val l, r = newBuilder
298 298 for (x <- this) (if (p(x)) l else r) += x
299 299 (l.result, r.result)
300 300 }
301 301
302 302 def groupBy[K](f: A => K): immutable.Map[K, Repr] = {
303 303 val m = mutable.Map.empty[K, Builder[A, Repr]]
304 304 for (elem <- this) {
305 305 val key = f(elem)
306 306 val bldr = m.getOrElseUpdate(key, newBuilder)
307 307 bldr += elem
308 308 }
309 309 val b = immutable.Map.newBuilder[K, Repr]
310 310 for ((k, v) <- m)
311 311 b += ((k, v.result))
312 312
313 313 b.result
314 314 }
315 315
316 316 /** Tests whether a predicate holds for all elements of this $coll.
317 317 *
318 318 * $mayNotTerminateInf
319 319 *
320 320 * @param p the predicate used to test elements.
321 321 * @return `true` if the given predicate `p` holds for all elements
322 322 * of this $coll, otherwise `false`.
323 323 */
324 324 def forall(p: A => Boolean): Boolean = {
325 325 var result = true
326 326 breakable {
327 327 for (x <- this)
328 328 if (!p(x)) { result = false; break }
329 329 }
330 330 result
331 331 }
332 332
333 333 /** Tests whether a predicate holds for some of the elements of this $coll.
334 334 *
335 335 * $mayNotTerminateInf
336 336 *
337 337 * @param p the predicate used to test elements.
338 338 * @return `true` if the given predicate `p` holds for some of the
339 339 * elements of this $coll, otherwise `false`.
340 340 */
341 341 def exists(p: A => Boolean): Boolean = {
342 342 var result = false
343 343 breakable {
344 344 for (x <- this)
345 345 if (p(x)) { result = true; break }
346 346 }
347 347 result
348 348 }
349 349
350 350 /** Finds the first element of the $coll satisfying a predicate, if any.
351 *
351 *
352 352 * $mayNotTerminateInf
353 353 * $orderDependent
354 354 *
355 355 * @param p the predicate used to test elements.
356 356 * @return an option value containing the first element in the $coll
357 357 * that satisfies `p`, or `None` if none exists.
358 358 */
359 359 def find(p: A => Boolean): Option[A] = {
360 360 var result: Option[A] = None
361 361 breakable {
362 362 for (x <- this)
363 363 if (p(x)) { result = Some(x); break }
364 364 }
365 365 result
366 366 }
367 367
368 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 370 def scanLeft[B, That](z: B)(op: (B, A) => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
371 371 val b = bf(repr)
372 372 b.sizeHint(this, 1)
373 373 var acc = z
374 374 b += acc
375 375 for (x <- this) { acc = op(acc, x); b += acc }
376 376 b.result
377 377 }
378 378
379 379 @migration(2, 9,
380 380 "This scanRight definition has changed in 2.9.\n" +
381 381 "The previous behavior can be reproduced with scanRight.reverse."
382 382 )
383 383 def scanRight[B, That](z: B)(op: (A, B) => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
384 384 var scanned = List(z)
385 385 var acc = z
386 386 for (x <- reversed) {
387 387 acc = op(x, acc)
388 388 scanned ::= acc
389 389 }
390 390 val b = bf(repr)
391 391 for (elem <- scanned) b += elem
392 392 b.result
393 393 }
394 394
395 395 /** Selects the first element of this $coll.
396 396 * $orderDependent
397 397 * @return the first element of this $coll.
398 398 * @throws `NoSuchElementException` if the $coll is empty.
399 399 */
400 400 def head: A = {
401 401 var result: () => A = () => throw new NoSuchElementException
402 402 breakable {
403 403 for (x <- this) {
404 404 result = () => x
405 405 break
406 406 }
407 407 }
408 408 result()
409 409 }
410 410
411 411 /** Optionally selects the first element.
412 412 * $orderDependent
413 413 * @return the first element of this $coll if it is nonempty, `None` if it is empty.
414 414 */
415 415 def headOption: Option[A] = if (isEmpty) None else Some(head)
416 416
417 417 /** Selects all elements except the first.
418 418 * $orderDependent
419 419 * @return a $coll consisting of all elements of this $coll
420 420 * except the first one.
421 421 * @throws `UnsupportedOperationException` if the $coll is empty.
422 */
422 */
423 423 override def tail: Repr = {
424 424 if (isEmpty) throw new UnsupportedOperationException("empty.tail")
425 425 drop(1)
426 426 }
427 427
428 428 /** Selects the last element.
429 429 * $orderDependent
430 430 * @return The last element of this $coll.
431 431 * @throws NoSuchElementException If the $coll is empty.
432 432 */
433 433 def last: A = {
434 434 var lst = head
435 435 for (x <- this)
436 436 lst = x
437 437 lst
438 438 }
439 439
440 440 /** Optionally selects the last element.
441 441 * $orderDependent
442 442 * @return the last element of this $coll$ if it is nonempty, `None` if it is empty.
443 443 */
444 444 def lastOption: Option[A] = if (isEmpty) None else Some(last)
445 445
446 446 /** Selects all elements except the last.
447 447 * $orderDependent
448 448 * @return a $coll consisting of all elements of this $coll
449 449 * except the last one.
450 450 * @throws `UnsupportedOperationException` if the $coll is empty.
451 451 */
452 452 def init: Repr = {
453 453 if (isEmpty) throw new UnsupportedOperationException("empty.init")
454 454 var lst = head
455 455 var follow = false
456 456 val b = newBuilder
457 457 b.sizeHint(this, -1)
458 458 for (x <- this.seq) {
459 459 if (follow) b += lst
460 460 else follow = true
461 461 lst = x
462 462 }
463 463 b.result
464 464 }
465 465
466 466 def take(n: Int): Repr = slice(0, n)
467 467
468 def drop(n: Int): Repr =
468 def drop(n: Int): Repr =
469 469 if (n <= 0) {
470 470 val b = newBuilder
471 471 b.sizeHint(this)
472 472 b ++= thisCollection result
473 473 }
474 474 else sliceWithKnownDelta(n, Int.MaxValue, -n)
475 475
476 476 def slice(from: Int, until: Int): Repr = sliceWithKnownBound(math.max(from, 0), until)
477 477
478 478 // Precondition: from >= 0, until > 0, builder already configured for building.
479 479 private[this] def sliceInternal(from: Int, until: Int, b: Builder[A, Repr]): Repr = {
480 480 var i = 0
481 481 breakable {
482 482 for (x <- this.seq) {
483 483 if (i >= from) b += x
484 484 i += 1
485 485 if (i >= until) break
486 486 }
487 487 }
488 488 b.result
489 489 }
490 490 // Precondition: from >= 0
491 491 private[scala] def sliceWithKnownDelta(from: Int, until: Int, delta: Int): Repr = {
492 492 val b = newBuilder
493 493 if (until <= from) b.result
494 494 else {
495 495 b.sizeHint(this, delta)
496 496 sliceInternal(from, until, b)
497 497 }
498 498 }
499 499 // Precondition: from >= 0
500 500 private[scala] def sliceWithKnownBound(from: Int, until: Int): Repr = {
501 501 val b = newBuilder
502 502 if (until <= from) b.result
503 503 else {
504 b.sizeHintBounded(until - from, this)
504 b.sizeHintBounded(until - from, this)
505 505 sliceInternal(from, until, b)
506 506 }
507 507 }
508 508
509 509 def takeWhile(p: A => Boolean): Repr = {
510 510 val b = newBuilder
511 511 breakable {
512 512 for (x <- this) {
513 513 if (!p(x)) break
514 514 b += x
515 515 }
516 516 }
517 517 b.result
518 518 }
519 519
520 520 def dropWhile(p: A => Boolean): Repr = {
521 521 val b = newBuilder
522 522 var go = false
523 523 for (x <- this) {
524 524 if (!p(x)) go = true
525 525 if (go) b += x
526 526 }
527 527 b.result
528 528 }
529 529
530 530 def span(p: A => Boolean): (Repr, Repr) = {
531 531 val l, r = newBuilder
532 532 var toLeft = true
533 533 for (x <- this) {
534 534 toLeft = toLeft && p(x)
535 535 (if (toLeft) l else r) += x
536 536 }
537 537 (l.result, r.result)
538 538 }
539 539
540 540 def splitAt(n: Int): (Repr, Repr) = {
541 541 val l, r = newBuilder
542 542 l.sizeHintBounded(n, this)
543 543 if (n >= 0) r.sizeHint(this, -n)
544 544 var i = 0
545 545 for (x <- this) {
546 546 (if (i < n) l else r) += x
547 547 i += 1
548 548 }
549 549 (l.result, r.result)
550 550 }
551 551
552 552 /** Iterates over the tails of this $coll. The first value will be this
553 553 * $coll and the final one will be an empty $coll, with the intervening
554 554 * values the results of successive applications of `tail`.
555 555 *
556 556 * @return an iterator over all the tails of this $coll
557 557 * @example `List(1,2,3).tails = Iterator(List(1,2,3), List(2,3), List(3), Nil)`
558 */
558 */
559 559 def tails: Iterator[Repr] = iterateUntilEmpty(_.tail)
560 560
561 561 /** Iterates over the inits of this $coll. The first value will be this
562 562 * $coll and the final one will be an empty $coll, with the intervening
563 563 * values the results of successive applications of `init`.
564 564 *
565 565 * @return an iterator over all the inits of this $coll
566 566 * @example `List(1,2,3).inits = Iterator(List(1,2,3), List(1,2), List(1), Nil)`
567 567 */
568 568 def inits: Iterator[Repr] = iterateUntilEmpty(_.init)
569 569
570 570 /** Copies elements of this $coll to an array.
571 571 * Fills the given array `xs` with at most `len` elements of
572 572 * this $coll, starting at position `start`.
573 573 * Copying will stop once either the end of the current $coll is reached,
574 574 * or the end of the array is reached, or `len` elements have been copied.
575 575 *
576 576 * $willNotTerminateInf
577 *
577 *
578 578 * @param xs the array to fill.
579 579 * @param start the starting index.
580 580 * @param len the maximal number of elements to copy.
581 * @tparam B the type of the elements of the array.
582 *
581 * @tparam B the type of the elements of the array.
582 *
583 583 *
584 584 * @usecase def copyToArray(xs: Array[A], start: Int, len: Int): Unit
585 585 */
586 586 def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) {
587 587 var i = start
588 588 val end = (start + len) min xs.length
589 589 breakable {
590 590 for (x <- this) {
591 591 if (i >= end) break
592 592 xs(i) = x
593 593 i += 1
594 594 }
595 595 }
596 596 }
597 597
598 598 def toTraversable: Traversable[A] = thisCollection
599 599 def toIterator: Iterator[A] = toStream.iterator
600 600 def toStream: Stream[A] = toBuffer.toStream
601 601
602 602 /** Converts this $coll to a string.
603 603 *
604 604 * @return a string representation of this collection. By default this
605 605 * string consists of the `stringPrefix` of this $coll,
606 606 * followed by all elements separated by commas and enclosed in parentheses.
607 607 */
608 608 override def toString = mkString(stringPrefix + "(", ", ", ")")
609 609
610 610 /** Defines the prefix of this object's `toString` representation.
611 611 *
612 612 * @return a string representation which starts the result of `toString`
613 613 * applied to this $coll. By default the string prefix is the
614 614 * simple name of the collection class $coll.
615 615 */
616 616 def stringPrefix : String = {
617 617 var string = repr.asInstanceOf[AnyRef].getClass.getName
618 618 val idx1 = string.lastIndexOf('.' : Int)
619 619 if (idx1 != -1) string = string.substring(idx1 + 1)
620 620 val idx2 = string.indexOf('$')
621 621 if (idx2 != -1) string = string.substring(0, idx2)
622 622 string
623 623 }
624 624
625 625 /** Creates a non-strict view of this $coll.
626 *
626 *
627 627 * @return a non-strict view of this $coll.
628 628 */
629 629 def view = new TraversableView[A, Repr] {
630 630 protected lazy val underlying = self.repr
631 631 override def foreach[U](f: A => U) = self foreach f
632 632 }
633 633
634 634 /** Creates a non-strict view of a slice of this $coll.
635 635 *
636 636 * Note: the difference between `view` and `slice` is that `view` produces
637 637 * a view of the current $coll, whereas `slice` produces a new $coll.
638 *
638 *
639 639 * Note: `view(from, to)` is equivalent to `view.slice(from, to)`
640 640 * $orderDependent
641 *
641 *
642 642 * @param from the index of the first element of the view
643 643 * @param until the index of the element following the view
644 644 * @return a non-strict view of a slice of this $coll, starting at index `from`
645 645 * and extending up to (but not including) index `until`.
646 646 */
647 647 def view(from: Int, until: Int): TraversableView[A, Repr] = view.slice(from, until)
648 648
649 649 /** Creates a non-strict filter of this $coll.
650 650 *
651 651 * Note: the difference between `c filter p` and `c withFilter p` is that
652 652 * the former creates a new collection, whereas the latter only
653 653 * restricts the domain of subsequent `map`, `flatMap`, `foreach`,
654 654 * and `withFilter` operations.
655 655 * $orderDependent
656 *
656 *
657 657 * @param p the predicate used to test elements.
658 658 * @return an object of class `WithFilter`, which supports
659 659 * `map`, `flatMap`, `foreach`, and `withFilter` operations.
660 660 * All these operations apply to those elements of this $coll which
661 661 * satisfy the predicate `p`.
662 662 */
663 663 def withFilter(p: A => Boolean): FilterMonadic[A, Repr] = new WithFilter(p)
664 664
665 665 /** A class supporting filtered operations. Instances of this class are
666 666 * returned by method `withFilter`.
667 667 */
668 668 class WithFilter(p: A => Boolean) extends FilterMonadic[A, Repr] {
669 669
670 670 /** Builds a new collection by applying a function to all elements of the
671 671 * outer $coll containing this `WithFilter` instance that satisfy predicate `p`.
672 672 *
673 673 * @param f the function to apply to each element.
674 674 * @tparam B the element type of the returned collection.
675 675 * @tparam That $thatinfo
676 676 * @param bf $bfinfo
677 677 * @return a new collection of type `That` resulting from applying
678 678 * the given function `f` to each element of the outer $coll
679 679 * that satisfies predicate `p` and collecting the results.
680 680 *
681 * @usecase def map[B](f: A => B): $Coll[B]
682 *
681 * @usecase def map[B](f: A => B): $Coll[B]
682 *
683 683 * @return a new $coll resulting from applying the given function
684 684 * `f` to each element of the outer $coll that satisfies
685 685 * predicate `p` and collecting the results.
686 686 */
687 687 def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
688 688 val b = bf(repr)
689 for (x <- self)
689 for (x <- self)
690 690 if (p(x)) b += f(x)
691 691 b.result
692 692 }
693 693
694 694 /** Builds a new collection by applying a function to all elements of the
695 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 698 * @param f the function to apply to each element.
699 699 * @tparam B the element type of the returned collection.
700 700 * @tparam That $thatinfo
701 701 * @param bf $bfinfo
702 702 * @return a new collection of type `That` resulting from applying
703 703 * the given collection-valued function `f` to each element
704 704 * of the outer $coll that satisfies predicate `p` and
705 705 * concatenating the results.
706 706 *
707 707 * @usecase def flatMap[B](f: A => TraversableOnce[B]): $Coll[B]
708 *
708 *
709 709 * @return a new $coll resulting from applying the given collection-valued function
710 710 * `f` to each element of the outer $coll that satisfies predicate `p` and concatenating the results.
711 711 */
712 712 def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
713 713 val b = bf(repr)
714 for (x <- self)
714 for (x <- self)
715 715 if (p(x)) b ++= f(x).seq
716 716 b.result
717 717 }
718 718
719 719 /** Applies a function `f` to all elements of the outer $coll containing
720 720 * this `WithFilter` instance that satisfy predicate `p`.
721 721 *
722 722 * @param f the function that is applied for its side-effect to every element.
723 723 * The result of function `f` is discarded.
724 *
725 * @tparam U the type parameter describing the result of function `f`.
724 *
725 * @tparam U the type parameter describing the result of function `f`.
726 726 * This result will always be ignored. Typically `U` is `Unit`,
727 727 * but this is not necessary.
728 728 *
729 729 * @usecase def foreach(f: A => Unit): Unit
730 */
731 def foreach[U](f: A => U): Unit =
732 for (x <- self)
730 */
731 def foreach[U](f: A => U): Unit =
732 for (x <- self)
733 733 if (p(x)) f(x)
734 734
735 735 /** Further refines the filter for this $coll.
736 736 *
737 737 * @param q the predicate used to test elements.
738 738 * @return an object of class `WithFilter`, which supports
739 739 * `map`, `flatMap`, `foreach`, and `withFilter` operations.
740 740 * All these operations apply to those elements of this $coll which
741 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 744 new WithFilter(x => p(x) && q(x))
745 745 }
746 746
747 747 // A helper for tails and inits.
748 748 private def iterateUntilEmpty(f: Traversable[A @uV] => Traversable[A @uV]): Iterator[Repr] = {
749 749 val it = Iterator.iterate(thisCollection)(f) takeWhile (x => !x.isEmpty)
750 750 it ++ Iterator(Nil) map (newBuilder ++= _ result)
751 751 }
752 752 }
753 753
754 754
755 755 </textarea>
756 756 </form>
757 757
758 758 <script>
759 759 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
760 760 lineNumbers: true,
761 761 matchBrackets: true,
762 762 theme: "ambiance",
763 763 mode: "text/x-scala"
764 764 });
765 765 </script>
766 766 </body>
767 767 </html>
@@ -1,195 +1,195 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: COBOL mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="../../addon/edit/matchbrackets.js"></script>
9 9 <script src="cobol.js"></script>
10 10 <link rel="stylesheet" href="../../theme/neat.css">
11 11 <link rel="stylesheet" href="../../theme/elegant.css">
12 12 <link rel="stylesheet" href="../../theme/erlang-dark.css">
13 13 <link rel="stylesheet" href="../../theme/night.css">
14 14 <link rel="stylesheet" href="../../theme/monokai.css">
15 15 <link rel="stylesheet" href="../../theme/cobalt.css">
16 16 <link rel="stylesheet" href="../../theme/eclipse.css">
17 17 <link rel="stylesheet" href="../../theme/rubyblue.css">
18 18 <link rel="stylesheet" href="../../theme/lesser-dark.css">
19 19 <link rel="stylesheet" href="../../theme/xq-dark.css">
20 20 <link rel="stylesheet" href="../../theme/xq-light.css">
21 21 <link rel="stylesheet" href="../../theme/ambiance.css">
22 22 <link rel="stylesheet" href="../../theme/blackboard.css">
23 23 <link rel="stylesheet" href="../../theme/vibrant-ink.css">
24 24 <link rel="stylesheet" href="../../theme/solarized.css">
25 25 <link rel="stylesheet" href="../../theme/twilight.css">
26 26 <link rel="stylesheet" href="../../theme/midnight.css">
27 27 <link rel="stylesheet" href="../../addon/dialog/dialog.css">
28 28 <script src="../../addon/selection/active-line.js"></script>
29 29 <script src="../../addon/search/search.js"></script>
30 30 <script src="../../addon/dialog/dialog.js"></script>
31 31 <script src="../../addon/search/searchcursor.js"></script>
32 32 <style>
33 33 .CodeMirror {
34 34 border: 1px solid #eee;
35 35 font-size : 20px;
36 36 height : auto !important;
37 37 }
38 38 .CodeMirror-activeline-background {background: #555555 !important;}
39 39 </style>
40 40 </head>
41 41 <body>
42 42 <p> Select Theme <select onchange="selectTheme()" id="selectTheme">
43 43 <option>default</option>
44 44 <option>ambiance</option>
45 45 <option>blackboard</option>
46 46 <option>cobalt</option>
47 47 <option>eclipse</option>
48 48 <option>elegant</option>
49 49 <option>erlang-dark</option>
50 50 <option>lesser-dark</option>
51 51 <option>midnight</option>
52 52 <option>monokai</option>
53 53 <option>neat</option>
54 54 <option>night</option>
55 55 <option>rubyblue</option>
56 56 <option>solarized dark</option>
57 57 <option>solarized light</option>
58 58 <option selected>twilight</option>
59 59 <option>vibrant-ink</option>
60 60 <option>xq-dark</option>
61 61 <option>xq-light</option>
62 62 </select> Select Font Size <select onchange="selectFontsize()" id="selectFontSize">
63 63 <option value="13px">13px</option>
64 64 <option value="14px">14px</option>
65 65 <option value="16px">16px</option>
66 66 <option value="18px">18px</option>
67 67 <option value="20px" selected="selected">20px</option>
68 68 <option value="24px">24px</option>
69 69 <option value="26px">26px</option>
70 70 <option value="28px">28px</option>
71 71 <option value="30px">30px</option>
72 72 <option value="32px">32px</option>
73 73 <option value="34px">34px</option>
74 74 <option value="36px">36px</option>
75 75 </select>
76 76 <label for="checkBoxReadOnly">Read-only</label>
77 77 <input type="checkbox" id="checkBoxReadOnly" onchange="selectReadOnly()">
78 78 <label for="id_tabToIndentSpace">Insert Spaces on Tab</label>
79 79 <input type="checkbox" id="id_tabToIndentSpace" onchange="tabToIndentSpace()">
80 80 </p>
81 81 <textarea id="code" name="code">
82 82 ---------1---------2---------3---------4---------5---------6---------7---------8
83 83 12345678911234567892123456789312345678941234567895123456789612345678971234567898
84 84 000010 IDENTIFICATION DIVISION. MODTGHERE
85 85 000020 PROGRAM-ID. SAMPLE.
86 000030 AUTHOR. TEST SAM.
86 000030 AUTHOR. TEST SAM.
87 87 000040 DATE-WRITTEN. 5 February 2013
88 88 000041
89 89 000042* A sample program just to show the form.
90 90 000043* The program copies its input to the output,
91 91 000044* and counts the number of records.
92 92 000045* At the end this number is printed.
93 93 000046
94 94 000050 ENVIRONMENT DIVISION.
95 95 000060 INPUT-OUTPUT SECTION.
96 96 000070 FILE-CONTROL.
97 97 000080 SELECT STUDENT-FILE ASSIGN TO SYSIN
98 98 000090 ORGANIZATION IS LINE SEQUENTIAL.
99 99 000100 SELECT PRINT-FILE ASSIGN TO SYSOUT
100 100 000110 ORGANIZATION IS LINE SEQUENTIAL.
101 101 000120
102 102 000130 DATA DIVISION.
103 103 000140 FILE SECTION.
104 104 000150 FD STUDENT-FILE
105 105 000160 RECORD CONTAINS 43 CHARACTERS
106 106 000170 DATA RECORD IS STUDENT-IN.
107 107 000180 01 STUDENT-IN PIC X(43).
108 108 000190
109 109 000200 FD PRINT-FILE
110 110 000210 RECORD CONTAINS 80 CHARACTERS
111 111 000220 DATA RECORD IS PRINT-LINE.
112 112 000230 01 PRINT-LINE PIC X(80).
113 113 000240
114 114 000250 WORKING-STORAGE SECTION.
115 115 000260 01 DATA-REMAINS-SWITCH PIC X(2) VALUE SPACES.
116 116 000261 01 RECORDS-WRITTEN PIC 99.
117 117 000270
118 118 000280 01 DETAIL-LINE.
119 119 000290 05 FILLER PIC X(7) VALUE SPACES.
120 120 000300 05 RECORD-IMAGE PIC X(43).
121 121 000310 05 FILLER PIC X(30) VALUE SPACES.
122 000311
122 000311
123 123 000312 01 SUMMARY-LINE.
124 124 000313 05 FILLER PIC X(7) VALUE SPACES.
125 125 000314 05 TOTAL-READ PIC 99.
126 126 000315 05 FILLER PIC X VALUE SPACE.
127 000316 05 FILLER PIC X(17)
127 000316 05 FILLER PIC X(17)
128 128 000317 VALUE 'Records were read'.
129 129 000318 05 FILLER PIC X(53) VALUE SPACES.
130 130 000319
131 131 000320 PROCEDURE DIVISION.
132 132 000321
133 133 000330 PREPARE-SENIOR-REPORT.
134 134 000340 OPEN INPUT STUDENT-FILE
135 135 000350 OUTPUT PRINT-FILE.
136 136 000351 MOVE ZERO TO RECORDS-WRITTEN.
137 137 000360 READ STUDENT-FILE
138 138 000370 AT END MOVE 'NO' TO DATA-REMAINS-SWITCH
139 139 000380 END-READ.
140 140 000390 PERFORM PROCESS-RECORDS
141 141 000410 UNTIL DATA-REMAINS-SWITCH = 'NO'.
142 142 000411 PERFORM PRINT-SUMMARY.
143 143 000420 CLOSE STUDENT-FILE
144 144 000430 PRINT-FILE.
145 145 000440 STOP RUN.
146 146 000450
147 147 000460 PROCESS-RECORDS.
148 148 000470 MOVE STUDENT-IN TO RECORD-IMAGE.
149 149 000480 MOVE DETAIL-LINE TO PRINT-LINE.
150 150 000490 WRITE PRINT-LINE.
151 151 000500 ADD 1 TO RECORDS-WRITTEN.
152 152 000510 READ STUDENT-FILE
153 153 000520 AT END MOVE 'NO' TO DATA-REMAINS-SWITCH
154 000530 END-READ.
154 000530 END-READ.
155 155 000540
156 156 000550 PRINT-SUMMARY.
157 157 000560 MOVE RECORDS-WRITTEN TO TOTAL-READ.
158 158 000570 MOVE SUMMARY-LINE TO PRINT-LINE.
159 000571 WRITE PRINT-LINE.
159 000571 WRITE PRINT-LINE.
160 160 000572
161 161 000580
162 162 </textarea>
163 163 <script>
164 164 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
165 165 lineNumbers: true,
166 166 matchBrackets: true,
167 167 mode: "text/x-cobol",
168 168 theme : "twilight",
169 169 styleActiveLine: true,
170 showCursorWhenSelecting : true,
170 showCursorWhenSelecting : true,
171 171 });
172 172 function selectTheme() {
173 173 var themeInput = document.getElementById("selectTheme");
174 174 var theme = themeInput.options[themeInput.selectedIndex].innerHTML;
175 175 editor.setOption("theme", theme);
176 176 }
177 177 function selectFontsize() {
178 178 var fontSizeInput = document.getElementById("selectFontSize");
179 179 var fontSize = fontSizeInput.options[fontSizeInput.selectedIndex].innerHTML;
180 180 editor.getWrapperElement().style["font-size"] = fontSize;
181 181 editor.refresh();
182 182 }
183 183 function selectReadOnly() {
184 184 editor.setOption("readOnly", document.getElementById("checkBoxReadOnly").checked);
185 185 }
186 186 function tabToIndentSpace() {
187 187 if (document.getElementById("id_tabToIndentSpace").checked) {
188 188 editor.setOption("extraKeys", {Tab: function(cm) { cm.replaceSelection(" ", "end"); }});
189 189 } else {
190 190 editor.setOption("extraKeys", {Tab: function(cm) { cm.replaceSelection(" ", "end"); }});
191 191 }
192 192 }
193 193 </script>
194 194 </body>
195 195 </html>
@@ -1,728 +1,728 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: CoffeeScript mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="coffeescript.js"></script>
9 9 <style>.CodeMirror {border-top: 1px solid silver; border-bottom: 1px solid silver;}</style>
10 10 <link rel="stylesheet" href="../../doc/docs.css">
11 11 </head>
12 12 <body>
13 13 <h1>CodeMirror: CoffeeScript mode</h1>
14 14 <form><textarea id="code" name="code">
15 15 # CoffeeScript mode for CodeMirror
16 16 # Copyright (c) 2011 Jeff Pickhardt, released under
17 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 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 23 # demonstrate CoffeeScript mode for CodeMirror.
24 24 #
25 25 # To download CoffeeScript mode for CodeMirror, go to:
26 26 # https://github.com/pickhardt/coffeescript-codemirror-mode
27 27
28 28 # **Underscore.coffee
29 29 # (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.**
30 30 # Underscore is freely distributable under the terms of the
31 31 # [MIT license](http://en.wikipedia.org/wiki/MIT_License).
32 32 # Portions of Underscore are inspired by or borrowed from
33 33 # [Prototype.js](http://prototypejs.org/api), Oliver Steele's
34 34 # [Functional](http://osteele.com), and John Resig's
35 35 # [Micro-Templating](http://ejohn.org).
36 36 # For all details and documentation:
37 37 # http://documentcloud.github.com/underscore/
38 38
39 39
40 40 # Baseline setup
41 41 # --------------
42 42
43 43 # Establish the root object, `window` in the browser, or `global` on the server.
44 44 root = this
45 45
46 46
47 47 # Save the previous value of the `_` variable.
48 48 previousUnderscore = root._
49 49
50 50 ### Multiline
51 51 comment
52 52 ###
53 53
54 54 # Establish the object that gets thrown to break out of a loop iteration.
55 55 # `StopIteration` is SOP on Mozilla.
56 56 breaker = if typeof(StopIteration) is 'undefined' then '__break__' else StopIteration
57 57
58 58
59 59 #### Docco style single line comment (title)
60 60
61 61
62 62 # Helper function to escape **RegExp** contents, because JS doesn't have one.
63 63 escapeRegExp = (string) -> string.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1')
64 64
65 65
66 66 # Save bytes in the minified (but not gzipped) version:
67 67 ArrayProto = Array.prototype
68 68 ObjProto = Object.prototype
69 69
70 70
71 71 # Create quick reference variables for speed access to core prototypes.
72 72 slice = ArrayProto.slice
73 73 unshift = ArrayProto.unshift
74 74 toString = ObjProto.toString
75 75 hasOwnProperty = ObjProto.hasOwnProperty
76 76 propertyIsEnumerable = ObjProto.propertyIsEnumerable
77 77
78 78
79 79 # All **ECMA5** native implementations we hope to use are declared here.
80 80 nativeForEach = ArrayProto.forEach
81 81 nativeMap = ArrayProto.map
82 82 nativeReduce = ArrayProto.reduce
83 83 nativeReduceRight = ArrayProto.reduceRight
84 84 nativeFilter = ArrayProto.filter
85 85 nativeEvery = ArrayProto.every
86 86 nativeSome = ArrayProto.some
87 87 nativeIndexOf = ArrayProto.indexOf
88 88 nativeLastIndexOf = ArrayProto.lastIndexOf
89 89 nativeIsArray = Array.isArray
90 90 nativeKeys = Object.keys
91 91
92 92
93 93 # Create a safe reference to the Underscore object for use below.
94 94 _ = (obj) -> new wrapper(obj)
95 95
96 96
97 97 # Export the Underscore object for **CommonJS**.
98 98 if typeof(exports) != 'undefined' then exports._ = _
99 99
100 100
101 101 # Export Underscore to global scope.
102 102 root._ = _
103 103
104 104
105 105 # Current version.
106 106 _.VERSION = '1.1.0'
107 107
108 108
109 109 # Collection Functions
110 110 # --------------------
111 111
112 112 # The cornerstone, an **each** implementation.
113 113 # Handles objects implementing **forEach**, arrays, and raw objects.
114 114 _.each = (obj, iterator, context) ->
115 115 try
116 116 if nativeForEach and obj.forEach is nativeForEach
117 117 obj.forEach iterator, context
118 118 else if _.isNumber obj.length
119 119 iterator.call context, obj[i], i, obj for i in [0...obj.length]
120 120 else
121 121 iterator.call context, val, key, obj for own key, val of obj
122 122 catch e
123 123 throw e if e isnt breaker
124 124 obj
125 125
126 126
127 127 # Return the results of applying the iterator to each element. Use JavaScript
128 128 # 1.6's version of **map**, if possible.
129 129 _.map = (obj, iterator, context) ->
130 130 return obj.map(iterator, context) if nativeMap and obj.map is nativeMap
131 131 results = []
132 132 _.each obj, (value, index, list) ->
133 133 results.push iterator.call context, value, index, list
134 134 results
135 135
136 136
137 137 # **Reduce** builds up a single result from a list of values. Also known as
138 138 # **inject**, or **foldl**. Uses JavaScript 1.8's version of **reduce**, if possible.
139 139 _.reduce = (obj, iterator, memo, context) ->
140 140 if nativeReduce and obj.reduce is nativeReduce
141 141 iterator = _.bind iterator, context if context
142 142 return obj.reduce iterator, memo
143 143 _.each obj, (value, index, list) ->
144 144 memo = iterator.call context, memo, value, index, list
145 145 memo
146 146
147 147
148 148 # The right-associative version of **reduce**, also known as **foldr**. Uses
149 149 # JavaScript 1.8's version of **reduceRight**, if available.
150 150 _.reduceRight = (obj, iterator, memo, context) ->
151 151 if nativeReduceRight and obj.reduceRight is nativeReduceRight
152 152 iterator = _.bind iterator, context if context
153 153 return obj.reduceRight iterator, memo
154 154 reversed = _.clone(_.toArray(obj)).reverse()
155 155 _.reduce reversed, iterator, memo, context
156 156
157 157
158 158 # Return the first value which passes a truth test.
159 159 _.detect = (obj, iterator, context) ->
160 160 result = null
161 161 _.each obj, (value, index, list) ->
162 162 if iterator.call context, value, index, list
163 163 result = value
164 164 _.breakLoop()
165 165 result
166 166
167 167
168 168 # Return all the elements that pass a truth test. Use JavaScript 1.6's
169 169 # **filter**, if it exists.
170 170 _.filter = (obj, iterator, context) ->
171 171 return obj.filter iterator, context if nativeFilter and obj.filter is nativeFilter
172 172 results = []
173 173 _.each obj, (value, index, list) ->
174 174 results.push value if iterator.call context, value, index, list
175 175 results
176 176
177 177
178 178 # Return all the elements for which a truth test fails.
179 179 _.reject = (obj, iterator, context) ->
180 180 results = []
181 181 _.each obj, (value, index, list) ->
182 182 results.push value if not iterator.call context, value, index, list
183 183 results
184 184
185 185
186 186 # Determine whether all of the elements match a truth test. Delegate to
187 187 # JavaScript 1.6's **every**, if it is present.
188 188 _.every = (obj, iterator, context) ->
189 189 iterator ||= _.identity
190 190 return obj.every iterator, context if nativeEvery and obj.every is nativeEvery
191 191 result = true
192 192 _.each obj, (value, index, list) ->
193 193 _.breakLoop() unless (result = result and iterator.call(context, value, index, list))
194 194 result
195 195
196 196
197 197 # Determine if at least one element in the object matches a truth test. Use
198 198 # JavaScript 1.6's **some**, if it exists.
199 199 _.some = (obj, iterator, context) ->
200 200 iterator ||= _.identity
201 201 return obj.some iterator, context if nativeSome and obj.some is nativeSome
202 202 result = false
203 203 _.each obj, (value, index, list) ->
204 204 _.breakLoop() if (result = iterator.call(context, value, index, list))
205 205 result
206 206
207 207
208 208 # Determine if a given value is included in the array or object,
209 209 # based on `===`.
210 210 _.include = (obj, target) ->
211 211 return _.indexOf(obj, target) isnt -1 if nativeIndexOf and obj.indexOf is nativeIndexOf
212 212 return true for own key, val of obj when val is target
213 213 false
214 214
215 215
216 216 # Invoke a method with arguments on every item in a collection.
217 217 _.invoke = (obj, method) ->
218 218 args = _.rest arguments, 2
219 219 (if method then val[method] else val).apply(val, args) for val in obj
220 220
221 221
222 222 # Convenience version of a common use case of **map**: fetching a property.
223 223 _.pluck = (obj, key) ->
224 224 _.map(obj, (val) -> val[key])
225 225
226 226
227 227 # Return the maximum item or (item-based computation).
228 228 _.max = (obj, iterator, context) ->
229 229 return Math.max.apply(Math, obj) if not iterator and _.isArray(obj)
230 230 result = computed: -Infinity
231 231 _.each obj, (value, index, list) ->
232 232 computed = if iterator then iterator.call(context, value, index, list) else value
233 233 computed >= result.computed and (result = {value: value, computed: computed})
234 234 result.value
235 235
236 236
237 237 # Return the minimum element (or element-based computation).
238 238 _.min = (obj, iterator, context) ->
239 239 return Math.min.apply(Math, obj) if not iterator and _.isArray(obj)
240 240 result = computed: Infinity
241 241 _.each obj, (value, index, list) ->
242 242 computed = if iterator then iterator.call(context, value, index, list) else value
243 243 computed < result.computed and (result = {value: value, computed: computed})
244 244 result.value
245 245
246 246
247 247 # Sort the object's values by a criterion produced by an iterator.
248 248 _.sortBy = (obj, iterator, context) ->
249 249 _.pluck(((_.map obj, (value, index, list) ->
250 250 {value: value, criteria: iterator.call(context, value, index, list)}
251 251 ).sort((left, right) ->
252 252 a = left.criteria; b = right.criteria
253 253 if a < b then -1 else if a > b then 1 else 0
254 254 )), 'value')
255 255
256 256
257 257 # Use a comparator function to figure out at what index an object should
258 258 # be inserted so as to maintain order. Uses binary search.
259 259 _.sortedIndex = (array, obj, iterator) ->
260 260 iterator ||= _.identity
261 261 low = 0
262 262 high = array.length
263 263 while low < high
264 264 mid = (low + high) >> 1
265 265 if iterator(array[mid]) < iterator(obj) then low = mid + 1 else high = mid
266 266 low
267 267
268 268
269 269 # Convert anything iterable into a real, live array.
270 270 _.toArray = (iterable) ->
271 271 return [] if (!iterable)
272 272 return iterable.toArray() if (iterable.toArray)
273 273 return iterable if (_.isArray(iterable))
274 274 return slice.call(iterable) if (_.isArguments(iterable))
275 275 _.values(iterable)
276 276
277 277
278 278 # Return the number of elements in an object.
279 279 _.size = (obj) -> _.toArray(obj).length
280 280
281 281
282 282 # Array Functions
283 283 # ---------------
284 284
285 285 # Get the first element of an array. Passing `n` will return the first N
286 286 # values in the array. Aliased as **head**. The `guard` check allows it to work
287 287 # with **map**.
288 288 _.first = (array, n, guard) ->
289 289 if n and not guard then slice.call(array, 0, n) else array[0]
290 290
291 291
292 292 # Returns everything but the first entry of the array. Aliased as **tail**.
293 293 # Especially useful on the arguments object. Passing an `index` will return
294 294 # the rest of the values in the array from that index onward. The `guard`
295 295 # check allows it to work with **map**.
296 296 _.rest = (array, index, guard) ->
297 297 slice.call(array, if _.isUndefined(index) or guard then 1 else index)
298 298
299 299
300 300 # Get the last element of an array.
301 301 _.last = (array) -> array[array.length - 1]
302 302
303 303
304 304 # Trim out all falsy values from an array.
305 305 _.compact = (array) -> item for item in array when item
306 306
307 307
308 308 # Return a completely flattened version of an array.
309 309 _.flatten = (array) ->
310 310 _.reduce array, (memo, value) ->
311 311 return memo.concat(_.flatten(value)) if _.isArray value
312 312 memo.push value
313 313 memo
314 314 , []
315 315
316 316
317 317 # Return a version of the array that does not contain the specified value(s).
318 318 _.without = (array) ->
319 319 values = _.rest arguments
320 320 val for val in _.toArray(array) when not _.include values, val
321 321
322 322
323 323 # Produce a duplicate-free version of the array. If the array has already
324 324 # been sorted, you have the option of using a faster algorithm.
325 325 _.uniq = (array, isSorted) ->
326 326 memo = []
327 327 for el, i in _.toArray array
328 328 memo.push el if i is 0 || (if isSorted is true then _.last(memo) isnt el else not _.include(memo, el))
329 329 memo
330 330
331 331
332 332 # Produce an array that contains every item shared between all the
333 333 # passed-in arrays.
334 334 _.intersect = (array) ->
335 335 rest = _.rest arguments
336 336 _.select _.uniq(array), (item) ->
337 337 _.all rest, (other) ->
338 338 _.indexOf(other, item) >= 0
339 339
340 340
341 341 # Zip together multiple lists into a single array -- elements that share
342 342 # an index go together.
343 343 _.zip = ->
344 344 length = _.max _.pluck arguments, 'length'
345 345 results = new Array length
346 346 for i in [0...length]
347 347 results[i] = _.pluck arguments, String i
348 348 results
349 349
350 350
351 351 # If the browser doesn't supply us with **indexOf** (I'm looking at you, MSIE),
352 352 # we need this function. Return the position of the first occurrence of an
353 353 # item in an array, or -1 if the item is not included in the array.
354 354 _.indexOf = (array, item) ->
355 355 return array.indexOf item if nativeIndexOf and array.indexOf is nativeIndexOf
356 356 i = 0; l = array.length
357 357 while l - i
358 358 if array[i] is item then return i else i++
359 359 -1
360 360
361 361
362 362 # Provide JavaScript 1.6's **lastIndexOf**, delegating to the native function,
363 363 # if possible.
364 364 _.lastIndexOf = (array, item) ->
365 365 return array.lastIndexOf(item) if nativeLastIndexOf and array.lastIndexOf is nativeLastIndexOf
366 366 i = array.length
367 367 while i
368 368 if array[i] is item then return i else i--
369 369 -1
370 370
371 371
372 372 # Generate an integer Array containing an arithmetic progression. A port of
373 373 # [the native Python **range** function](http://docs.python.org/library/functions.html#range).
374 374 _.range = (start, stop, step) ->
375 375 a = arguments
376 376 solo = a.length <= 1
377 377 i = start = if solo then 0 else a[0]
378 378 stop = if solo then a[0] else a[1]
379 379 step = a[2] or 1
380 380 len = Math.ceil((stop - start) / step)
381 381 return [] if len <= 0
382 382 range = new Array len
383 383 idx = 0
384 384 loop
385 385 return range if (if step > 0 then i - stop else stop - i) >= 0
386 386 range[idx] = i
387 387 idx++
388 388 i+= step
389 389
390 390
391 391 # Function Functions
392 392 # ------------------
393 393
394 394 # Create a function bound to a given object (assigning `this`, and arguments,
395 395 # optionally). Binding with arguments is also known as **curry**.
396 396 _.bind = (func, obj) ->
397 397 args = _.rest arguments, 2
398 398 -> func.apply obj or root, args.concat arguments
399 399
400 400
401 401 # Bind all of an object's methods to that object. Useful for ensuring that
402 402 # all callbacks defined on an object belong to it.
403 403 _.bindAll = (obj) ->
404 404 funcs = if arguments.length > 1 then _.rest(arguments) else _.functions(obj)
405 405 _.each funcs, (f) -> obj[f] = _.bind obj[f], obj
406 406 obj
407 407
408 408
409 409 # Delays a function for the given number of milliseconds, and then calls
410 410 # it with the arguments supplied.
411 411 _.delay = (func, wait) ->
412 412 args = _.rest arguments, 2
413 413 setTimeout((-> func.apply(func, args)), wait)
414 414
415 415
416 416 # Memoize an expensive function by storing its results.
417 417 _.memoize = (func, hasher) ->
418 418 memo = {}
419 419 hasher or= _.identity
420 420 ->
421 421 key = hasher.apply this, arguments
422 422 return memo[key] if key of memo
423 423 memo[key] = func.apply this, arguments
424 424
425 425
426 426 # Defers a function, scheduling it to run after the current call stack has
427 427 # cleared.
428 428 _.defer = (func) ->
429 429 _.delay.apply _, [func, 1].concat _.rest arguments
430 430
431 431
432 432 # Returns the first function passed as an argument to the second,
433 433 # allowing you to adjust arguments, run code before and after, and
434 434 # conditionally execute the original function.
435 435 _.wrap = (func, wrapper) ->
436 436 -> wrapper.apply wrapper, [func].concat arguments
437 437
438 438
439 439 # Returns a function that is the composition of a list of functions, each
440 440 # consuming the return value of the function that follows.
441 441 _.compose = ->
442 442 funcs = arguments
443 443 ->
444 444 args = arguments
445 445 for i in [funcs.length - 1..0] by -1
446 446 args = [funcs[i].apply(this, args)]
447 447 args[0]
448 448
449 449
450 450 # Object Functions
451 451 # ----------------
452 452
453 453 # Retrieve the names of an object's properties.
454 454 _.keys = nativeKeys or (obj) ->
455 455 return _.range 0, obj.length if _.isArray(obj)
456 456 key for key, val of obj
457 457
458 458
459 459 # Retrieve the values of an object's properties.
460 460 _.values = (obj) ->
461 461 _.map obj, _.identity
462 462
463 463
464 464 # Return a sorted list of the function names available in Underscore.
465 465 _.functions = (obj) ->
466 466 _.filter(_.keys(obj), (key) -> _.isFunction(obj[key])).sort()
467 467
468 468
469 469 # Extend a given object with all of the properties in a source object.
470 470 _.extend = (obj) ->
471 471 for source in _.rest(arguments)
472 472 obj[key] = val for key, val of source
473 473 obj
474 474
475 475
476 476 # Create a (shallow-cloned) duplicate of an object.
477 477 _.clone = (obj) ->
478 478 return obj.slice 0 if _.isArray obj
479 479 _.extend {}, obj
480 480
481 481
482 482 # Invokes interceptor with the obj, and then returns obj.
483 483 # The primary purpose of this method is to "tap into" a method chain,
484 484 # in order to perform operations on intermediate results within
485 485 the chain.
486 486 _.tap = (obj, interceptor) ->
487 487 interceptor obj
488 488 obj
489 489
490 490
491 491 # Perform a deep comparison to check if two objects are equal.
492 492 _.isEqual = (a, b) ->
493 493 # Check object identity.
494 494 return true if a is b
495 495 # Different types?
496 496 atype = typeof(a); btype = typeof(b)
497 497 return false if atype isnt btype
498 498 # Basic equality test (watch out for coercions).
499 499 return true if `a == b`
500 500 # One is falsy and the other truthy.
501 501 return false if (!a and b) or (a and !b)
502 502 # One of them implements an `isEqual()`?
503 503 return a.isEqual(b) if a.isEqual
504 504 # Check dates' integer values.
505 505 return a.getTime() is b.getTime() if _.isDate(a) and _.isDate(b)
506 506 # Both are NaN?
507 507 return false if _.isNaN(a) and _.isNaN(b)
508 508 # Compare regular expressions.
509 509 if _.isRegExp(a) and _.isRegExp(b)
510 510 return a.source is b.source and
511 511 a.global is b.global and
512 512 a.ignoreCase is b.ignoreCase and
513 513 a.multiline is b.multiline
514 514 # If a is not an object by this point, we can't handle it.
515 515 return false if atype isnt 'object'
516 516 # Check for different array lengths before comparing contents.
517 517 return false if a.length and (a.length isnt b.length)
518 518 # Nothing else worked, deep compare the contents.
519 519 aKeys = _.keys(a); bKeys = _.keys(b)
520 520 # Different object sizes?
521 521 return false if aKeys.length isnt bKeys.length
522 522 # Recursive comparison of contents.
523 523 return false for key, val of a when !(key of b) or !_.isEqual(val, b[key])
524 524 true
525 525
526 526
527 527 # Is a given array or object empty?
528 528 _.isEmpty = (obj) ->
529 529 return obj.length is 0 if _.isArray(obj) or _.isString(obj)
530 530 return false for own key of obj
531 531 true
532 532
533 533
534 534 # Is a given value a DOM element?
535 535 _.isElement = (obj) -> obj and obj.nodeType is 1
536 536
537 537
538 538 # Is a given value an array?
539 539 _.isArray = nativeIsArray or (obj) -> !!(obj and obj.concat and obj.unshift and not obj.callee)
540 540
541 541
542 542 # Is a given variable an arguments object?
543 543 _.isArguments = (obj) -> obj and obj.callee
544 544
545 545
546 546 # Is the given value a function?
547 547 _.isFunction = (obj) -> !!(obj and obj.constructor and obj.call and obj.apply)
548 548
549 549
550 550 # Is the given value a string?
551 551 _.isString = (obj) -> !!(obj is '' or (obj and obj.charCodeAt and obj.substr))
552 552
553 553
554 554 # Is a given value a number?
555 555 _.isNumber = (obj) -> (obj is +obj) or toString.call(obj) is '[object Number]'
556 556
557 557
558 558 # Is a given value a boolean?
559 559 _.isBoolean = (obj) -> obj is true or obj is false
560 560
561 561
562 562 # Is a given value a Date?
563 563 _.isDate = (obj) -> !!(obj and obj.getTimezoneOffset and obj.setUTCFullYear)
564 564
565 565
566 566 # Is the given value a regular expression?
567 567 _.isRegExp = (obj) -> !!(obj and obj.exec and (obj.ignoreCase or obj.ignoreCase is false))
568 568
569 569
570 570 # Is the given value NaN -- this one is interesting. `NaN != NaN`, and
571 571 # `isNaN(undefined) == true`, so we make sure it's a number first.
572 572 _.isNaN = (obj) -> _.isNumber(obj) and window.isNaN(obj)
573 573
574 574
575 575 # Is a given value equal to null?
576 576 _.isNull = (obj) -> obj is null
577 577
578 578
579 579 # Is a given variable undefined?
580 580 _.isUndefined = (obj) -> typeof obj is 'undefined'
581 581
582 582
583 583 # Utility Functions
584 584 # -----------------
585 585
586 586 # Run Underscore.js in noConflict mode, returning the `_` variable to its
587 587 # previous owner. Returns a reference to the Underscore object.
588 588 _.noConflict = ->
589 589 root._ = previousUnderscore
590 590 this
591 591
592 592
593 593 # Keep the identity function around for default iterators.
594 594 _.identity = (value) -> value
595 595
596 596
597 597 # Run a function `n` times.
598 598 _.times = (n, iterator, context) ->
599 599 iterator.call context, i for i in [0...n]
600 600
601 601
602 602 # Break out of the middle of an iteration.
603 603 _.breakLoop = -> throw breaker
604 604
605 605
606 606 # Add your own custom functions to the Underscore object, ensuring that
607 607 # they're correctly added to the OOP wrapper as well.
608 608 _.mixin = (obj) ->
609 609 for name in _.functions(obj)
610 610 addToWrapper name, _[name] = obj[name]
611 611
612 612
613 613 # Generate a unique integer id (unique within the entire client session).
614 614 # Useful for temporary DOM ids.
615 615 idCounter = 0
616 616 _.uniqueId = (prefix) ->
617 617 (prefix or '') + idCounter++
618 618
619 619
620 620 # By default, Underscore uses **ERB**-style template delimiters, change the
621 621 # following template settings to use alternative delimiters.
622 622 _.templateSettings = {
623 623 start: '<%'
624 624 end: '%>'
625 625 interpolate: /<%=(.+?)%>/g
626 626 }
627 627
628 628
629 629 # JavaScript templating a-la **ERB**, pilfered from John Resig's
630 630 # *Secrets of the JavaScript Ninja*, page 83.
631 631 # Single-quote fix from Rick Strahl.
632 632 # With alterations for arbitrary delimiters, and to preserve whitespace.
633 633 _.template = (str, data) ->
634 634 c = _.templateSettings
635 635 endMatch = new RegExp("'(?=[^"+c.end.substr(0, 1)+"]*"+escapeRegExp(c.end)+")","g")
636 636 fn = new Function 'obj',
637 637 'var p=[],print=function(){p.push.apply(p,arguments);};' +
638 638 'with(obj||{}){p.push(\'' +
639 639 str.replace(/\r/g, '\\r')
640 640 .replace(/\n/g, '\\n')
641 641 .replace(/\t/g, '\\t')
642 642 .replace(endMatch,"���")
643 643 .split("'").join("\\'")
644 644 .split("���").join("'")
645 645 .replace(c.interpolate, "',$1,'")
646 646 .split(c.start).join("');")
647 647 .split(c.end).join("p.push('") +
648 648 "');}return p.join('');"
649 649 if data then fn(data) else fn
650 650
651 651
652 652 # Aliases
653 653 # -------
654 654
655 655 _.forEach = _.each
656 656 _.foldl = _.inject = _.reduce
657 657 _.foldr = _.reduceRight
658 658 _.select = _.filter
659 659 _.all = _.every
660 660 _.any = _.some
661 661 _.contains = _.include
662 662 _.head = _.first
663 663 _.tail = _.rest
664 664 _.methods = _.functions
665 665
666 666
667 667 # Setup the OOP Wrapper
668 668 # ---------------------
669 669
670 670 # If Underscore is called as a function, it returns a wrapped object that
671 671 # can be used OO-style. This wrapper holds altered versions of all the
672 672 # underscore functions. Wrapped objects may be chained.
673 673 wrapper = (obj) ->
674 674 this._wrapped = obj
675 675 this
676 676
677 677
678 678 # Helper function to continue chaining intermediate results.
679 679 result = (obj, chain) ->
680 680 if chain then _(obj).chain() else obj
681 681
682 682
683 683 # A method to easily add functions to the OOP wrapper.
684 684 addToWrapper = (name, func) ->
685 685 wrapper.prototype[name] = ->
686 686 args = _.toArray arguments
687 687 unshift.call args, this._wrapped
688 688 result func.apply(_, args), this._chain
689 689
690 690
691 691 # Add all ofthe Underscore functions to the wrapper object.
692 692 _.mixin _
693 693
694 694
695 695 # Add all mutator Array functions to the wrapper.
696 696 _.each ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], (name) ->
697 697 method = Array.prototype[name]
698 698 wrapper.prototype[name] = ->
699 699 method.apply(this._wrapped, arguments)
700 700 result(this._wrapped, this._chain)
701 701
702 702
703 703 # Add all accessor Array functions to the wrapper.
704 704 _.each ['concat', 'join', 'slice'], (name) ->
705 705 method = Array.prototype[name]
706 706 wrapper.prototype[name] = ->
707 707 result(method.apply(this._wrapped, arguments), this._chain)
708 708
709 709
710 710 # Start chaining a wrapped Underscore object.
711 711 wrapper::chain = ->
712 712 this._chain = true
713 713 this
714 714
715 715
716 716 # Extracts the result from a wrapped and chained object.
717 717 wrapper::value = -> this._wrapped
718 718 </textarea></form>
719 719 <script>
720 720 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
721 721 </script>
722 722
723 723 <p><strong>MIME types defined:</strong> <code>text/x-coffeescript</code>.</p>
724 724
725 725 <p>The CoffeeScript mode was written by Jeff Pickhardt (<a href="LICENSE">license</a>).</p>
726 726
727 727 </body>
728 728 </html>
@@ -1,105 +1,105 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: Diff mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="diff.js"></script>
9 9 <style>
10 10 .CodeMirror {border-top: 1px solid #ddd; border-bottom: 1px solid #ddd;}
11 11 span.cm-meta {color: #a0b !important;}
12 12 span.cm-error { background-color: black; opacity: 0.4;}
13 13 span.cm-error.cm-string { background-color: red; }
14 14 span.cm-error.cm-tag { background-color: #2b2; }
15 15 </style>
16 16 <link rel="stylesheet" href="../../doc/docs.css">
17 17 </head>
18 18 <body>
19 19 <h1>CodeMirror: Diff mode</h1>
20 20 <form><textarea id="code" name="code">
21 21 diff --git a/index.html b/index.html
22 22 index c1d9156..7764744 100644
23 23 --- a/index.html
24 24 +++ b/index.html
25 25 @@ -95,7 +95,8 @@ StringStream.prototype = {
26 26 <script>
27 27 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
28 28 lineNumbers: true,
29 29 - autoMatchBrackets: true
30 30 + autoMatchBrackets: true,
31 31 + onGutterClick: function(x){console.log(x);}
32 32 });
33 33 </script>
34 34 </body>
35 35 diff --git a/lib/codemirror.js b/lib/codemirror.js
36 36 index 04646a9..9a39cc7 100644
37 37 --- a/lib/codemirror.js
38 38 +++ b/lib/codemirror.js
39 39 @@ -399,10 +399,16 @@ var CodeMirror = (function() {
40 40 }
41
41
42 42 function onMouseDown(e) {
43 - var start = posFromMouse(e), last = start;
43 - var start = posFromMouse(e), last = start;
44 44 + var start = posFromMouse(e), last = start, target = e.target();
45 45 if (!start) return;
46 46 setCursor(start.line, start.ch, false);
47 47 if (e.button() != 1) return;
48 + if (target.parentNode == gutter) {
48 + if (target.parentNode == gutter) {
49 49 + if (options.onGutterClick)
50 50 + options.onGutterClick(indexOf(gutter.childNodes, target) + showingFrom);
51 51 + return;
52 52 + }
53 53 +
54 54 if (!focused) onFocus();
55
55
56 56 e.stop();
57 57 @@ -808,7 +814,7 @@ var CodeMirror = (function() {
58 58 for (var i = showingFrom; i < showingTo; ++i) {
59 59 var marker = lines[i].gutterMarker;
60 60 if (marker) html.push('<div class="' + marker.style + '">' + htmlEscape(marker.text) + '</div>');
61 61 - else html.push("<div>" + (options.lineNumbers ? i + 1 : "\u00a0") + "</div>");
62 62 + else html.push("<div>" + (options.lineNumbers ? i + options.firstLineNumber : "\u00a0") + "</div>");
63 63 }
64 64 gutter.style.display = "none"; // TODO test whether this actually helps
65 65 gutter.innerHTML = html.join("");
66 66 @@ -1371,10 +1377,8 @@ var CodeMirror = (function() {
67 67 if (option == "parser") setParser(value);
68 68 else if (option === "lineNumbers") setLineNumbers(value);
69 69 else if (option === "gutter") setGutter(value);
70 70 - else if (option === "readOnly") options.readOnly = value;
71 71 - else if (option === "indentUnit") {options.indentUnit = indentUnit = value; setParser(options.parser);}
72 72 - else if (/^(?:enterMode|tabMode|indentWithTabs|readOnly|autoMatchBrackets|undoDepth)$/.test(option)) options[option] = value;
73 73 - else throw new Error("Can't set option " + option);
74 74 + else if (option === "indentUnit") {options.indentUnit = value; setParser(options.parser);}
75 75 + else options[option] = value;
76 76 },
77 77 cursorCoords: cursorCoords,
78 78 undo: operation(undo),
79 79 @@ -1402,7 +1406,8 @@ var CodeMirror = (function() {
80 80 replaceRange: operation(replaceRange),
81
81
82 82 operation: function(f){return operation(f)();},
83 83 - refresh: function(){updateDisplay([{from: 0, to: lines.length}]);}
84 84 + refresh: function(){updateDisplay([{from: 0, to: lines.length}]);},
85 85 + getInputField: function(){return input;}
86 86 };
87 87 return instance;
88 88 }
89 89 @@ -1420,6 +1425,7 @@ var CodeMirror = (function() {
90 90 readOnly: false,
91 91 onChange: null,
92 92 onCursorActivity: null,
93 93 + onGutterClick: null,
94 94 autoMatchBrackets: false,
95 95 workTime: 200,
96 96 workDelay: 300,
97 97 </textarea></form>
98 98 <script>
99 99 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
100 100 </script>
101 101
102 102 <p><strong>MIME types defined:</strong> <code>text/x-diff</code>.</p>
103 103
104 104 </body>
105 105 </html>
@@ -1,39 +1,39 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <title>CodeMirror: ECL mode</title>
5 5 <link rel="stylesheet" href="../../lib/codemirror.css">
6 6 <script src="../../lib/codemirror.js"></script>
7 7 <script src="ecl.js"></script>
8 8 <link rel="stylesheet" href="../../doc/docs.css">
9 9 <style>.CodeMirror {border: 1px solid black;}</style>
10 10 </head>
11 11 <body>
12 12 <h1>CodeMirror: ECL mode</h1>
13 13 <form><textarea id="code" name="code">
14 14 /*
15 15 sample useless code to demonstrate ecl syntax highlighting
16 16 this is a multiline comment!
17 17 */
18 18
19 19 // this is a singleline comment!
20 20
21 21 import ut;
22 r :=
22 r :=
23 23 record
24 24 string22 s1 := '123';
25 25 integer4 i1 := 123;
26 26 end;
27 27 #option('tmp', true);
28 28 d := dataset('tmp::qb', r, thor);
29 29 output(d);
30 30 </textarea></form>
31 31 <script>
32 32 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
33 33 </script>
34 34
35 35 <p>Based on CodeMirror's clike mode. For more information see <a href="http://hpccsystems.com">HPCC Systems</a> web site.</p>
36 36 <p><strong>MIME types defined:</strong> <code>text/x-ecl</code>.</p>
37 37
38 38 </body>
39 39 </html>
@@ -1,64 +1,64 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: Erlang mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="../../addon/edit/matchbrackets.js"></script>
9 9 <script src="erlang.js"></script>
10 10 <link rel="stylesheet" href="../../theme/erlang-dark.css">
11 11 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
12 12 <link rel="stylesheet" href="../../doc/docs.css">
13 13 </head>
14 14 <body>
15 15 <h1>CodeMirror: Erlang mode</h1>
16 16
17 17 <form><textarea id="code" name="code">
18 18 %% -*- mode: erlang; erlang-indent-level: 2 -*-
19 19 %%% Created : 7 May 2012 by mats cronqvist <masse@klarna.com>
20 20
21 21 %% @doc
22 22 %% Demonstrates how to print a record.
23 23 %% @end
24 24
25 25 -module('ex').
26 26 -author('mats cronqvist').
27 27 -export([demo/0,
28 28 rec_info/1]).
29 29
30 30 -record(demo,{a="One",b="Two",c="Three",d="Four"}).
31 31
32 32 rec_info(demo) -> record_info(fields,demo).
33 33
34 34 demo() -> expand_recs(?MODULE,#demo{a="A",b="BB"}).
35
35
36 36 expand_recs(M,List) when is_list(List) ->
37 37 [expand_recs(M,L)||L<-List];
38 38 expand_recs(M,Tup) when is_tuple(Tup) ->
39 39 case tuple_size(Tup) of
40 40 L when L < 1 -> Tup;
41 41 L ->
42 42 try Fields = M:rec_info(element(1,Tup)),
43 43 L = length(Fields)+1,
44 44 lists:zip(Fields,expand_recs(M,tl(tuple_to_list(Tup))))
45 45 catch _:_ ->
46 46 list_to_tuple(expand_recs(M,tuple_to_list(Tup)))
47 47 end
48 48 end;
49 49 expand_recs(_,Term) ->
50 50 Term.
51 51 </textarea></form>
52 52
53 53 <script>
54 54 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
55 55 lineNumbers: true,
56 56 matchBrackets: true,
57 57 extraKeys: {"Tab": "indentAuto"},
58 58 theme: "erlang-dark"
59 59 });
60 60 </script>
61 61
62 62 <p><strong>MIME types defined:</strong> <code>text/x-erlang</code>.</p>
63 63 </body>
64 64 </html>
@@ -1,57 +1,57 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: Gas mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="gas.js"></script>
9 9 <link rel="stylesheet" href="../../doc/docs.css">
10 10 <style>.CodeMirror {border: 2px inset #dee;}</style>
11 11 </head>
12 12 <body>
13 13 <h1>CodeMirror: Gas mode</h1>
14 14
15 15 <form>
16 16 <textarea id="code" name="code">
17 17 .syntax unified
18 18 .global main
19 19
20 /*
20 /*
21 21 * A
22 22 * multi-line
23 23 * comment.
24 24 */
25 25
26 26 @ A single line comment.
27 27
28 28 main:
29 29 push {sp, lr}
30 30 ldr r0, =message
31 31 bl puts
32 32 mov r0, #0
33 33 pop {sp, pc}
34 34
35 35 message:
36 36 .asciz "Hello world!<br />"
37 37 </textarea>
38 38 </form>
39 39
40 40 <script>
41 41 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
42 42 lineNumbers: true,
43 43 mode: {name: "gas", architecture: "ARMv6"},
44 44 });
45 45 </script>
46 46
47 47 <p>Handles AT&amp;T assembler syntax (more specifically this handles
48 48 the GNU Assembler (gas) syntax.)
49 49 It takes a single optional configuration parameter:
50 50 <code>architecture</code>, which can be one of <code>"ARM"</code>,
51 51 <code>"ARMv6"</code> or <code>"x86"</code>.
52 52 Including the parameter adds syntax for the registers and special
53 53 directives for the supplied architecture.
54 54
55 55 <p><strong>MIME types defined:</strong> <code>text/x-gas</code></p>
56 56 </body>
57 57 </html>
@@ -1,74 +1,74 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: GFM mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="../../addon/mode/overlay.js"></script>
9 9 <script src="../xml/xml.js"></script>
10 10 <script src="../markdown/markdown.js"></script>
11 11 <script src="gfm.js"></script>
12
12
13 13 <!-- Code block highlighting modes -->
14 14 <script src="../javascript/javascript.js"></script>
15 15 <script src="../css/css.js"></script>
16 16 <script src="../htmlmixed/htmlmixed.js"></script>
17 17 <script src="../clike/clike.js"></script>
18
18
19 19 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
20 20 <link rel="stylesheet" href="../../doc/docs.css">
21 21 </head>
22 22 <body>
23 23 <h1>CodeMirror: GFM mode</h1>
24 24
25 25 <form><textarea id="code" name="code">
26 26 GitHub Flavored Markdown
27 27 ========================
28 28
29 29 Everything from markdown plus GFM features:
30 30
31 31 ## URL autolinking
32 32
33 33 Underscores_are_allowed_between_words.
34 34
35 35 ## Fenced code blocks (and syntax highlighting)
36 36
37 37 ```javascript
38 38 for (var i = 0; i &lt; items.length; i++) {
39 39 console.log(items[i], i); // log them
40 40 }
41 41 ```
42 42
43 43 ## Task Lists
44 44
45 45 - [ ] Incomplete task list item
46 46 - [x] **Completed** task list item
47 47
48 48 ## A bit of GitHub spice
49 49
50 50 * SHA: be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
51 51 * User@SHA ref: mojombo@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
52 52 * User/Project@SHA: mojombo/god@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
53 53 * \#Num: #1
54 54 * User/#Num: mojombo#1
55 55 * User/Project#Num: mojombo/god#1
56 56
57 57 See http://github.github.com/github-flavored-markdown/.
58 58
59 59 </textarea></form>
60 60
61 61 <script>
62 62 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
63 63 mode: 'gfm',
64 64 lineNumbers: true,
65 65 theme: "default"
66 66 });
67 67 </script>
68 68
69 69 <p>Optionally depends on other modes for properly highlighted code blocks.</p>
70 70
71 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 73 </body>
74 74 </html>
@@ -1,74 +1,74 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: Go mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <link rel="stylesheet" href="../../theme/elegant.css">
8 8 <script src="../../lib/codemirror.js"></script>
9 9 <script src="../../addon/edit/matchbrackets.js"></script>
10 10 <script src="go.js"></script>
11 11 <link rel="stylesheet" href="../../doc/docs.css">
12 12 <style>.CodeMirror {border:1px solid #999; background:#ffc}</style>
13 13 </head>
14 14 <body>
15 15 <h1>CodeMirror: Go mode</h1>
16 16
17 17 <form><textarea id="code" name="code">
18 18 // Prime Sieve in Go.
19 19 // Taken from the Go specification.
20 20 // Copyright © The Go Authors.
21 21
22 22 package main
23 23
24 24 import "fmt"
25 25
26 26 // Send the sequence 2, 3, 4, ... to channel 'ch'.
27 27 func generate(ch chan&lt;- int) {
28 for i := 2; ; i++ {
29 ch &lt;- i // Send 'i' to channel 'ch'
30 }
28 for i := 2; ; i++ {
29 ch &lt;- i // Send 'i' to channel 'ch'
30 }
31 31 }
32 32
33 33 // Copy the values from channel 'src' to channel 'dst',
34 34 // removing those divisible by 'prime'.
35 35 func filter(src &lt;-chan int, dst chan&lt;- int, prime int) {
36 for i := range src { // Loop over values received from 'src'.
37 if i%prime != 0 {
38 dst &lt;- i // Send 'i' to channel 'dst'.
39 }
40 }
36 for i := range src { // Loop over values received from 'src'.
37 if i%prime != 0 {
38 dst &lt;- i // Send 'i' to channel 'dst'.
39 }
40 }
41 41 }
42 42
43 43 // The prime sieve: Daisy-chain filter processes together.
44 44 func sieve() {
45 ch := make(chan int) // Create a new channel.
46 go generate(ch) // Start generate() as a subprocess.
47 for {
48 prime := &lt;-ch
49 fmt.Print(prime, "\n")
50 ch1 := make(chan int)
51 go filter(ch, ch1, prime)
52 ch = ch1
53 }
45 ch := make(chan int) // Create a new channel.
46 go generate(ch) // Start generate() as a subprocess.
47 for {
48 prime := &lt;-ch
49 fmt.Print(prime, "\n")
50 ch1 := make(chan int)
51 go filter(ch, ch1, prime)
52 ch = ch1
53 }
54 54 }
55 55
56 56 func main() {
57 sieve()
57 sieve()
58 58 }
59 59 </textarea></form>
60 60
61 61 <script>
62 62 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
63 63 theme: "elegant",
64 64 matchBrackets: true,
65 65 indentUnit: 8,
66 66 tabSize: 8,
67 67 indentWithTabs: true,
68 68 mode: "text/x-go"
69 69 });
70 70 </script>
71 71
72 72 <p><strong>MIME type:</strong> <code>text/x-go</code></p>
73 73 </body>
74 74 </html>
@@ -1,62 +1,62 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: Haskell mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="../../addon/edit/matchbrackets.js"></script>
9 9 <script src="haskell.js"></script>
10 10 <link rel="stylesheet" href="../../theme/elegant.css">
11 11 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
12 12 <link rel="stylesheet" href="../../doc/docs.css">
13 13 </head>
14 14 <body>
15 15 <h1>CodeMirror: Haskell mode</h1>
16 16
17 17 <form><textarea id="code" name="code">
18 18 module UniquePerms (
19 19 uniquePerms
20 20 )
21 21 where
22 22
23 23 -- | Find all unique permutations of a list where there might be duplicates.
24 24 uniquePerms :: (Eq a) => [a] -> [[a]]
25 25 uniquePerms = permBag . makeBag
26 26
27 27 -- | An unordered collection where duplicate values are allowed,
28 28 -- but represented with a single value and a count.
29 29 type Bag a = [(a, Int)]
30 30
31 31 makeBag :: (Eq a) => [a] -> Bag a
32 32 makeBag [] = []
33 33 makeBag (a:as) = mix a $ makeBag as
34 34 where
35 35 mix a [] = [(a,1)]
36 36 mix a (bn@(b,n):bs) | a == b = (b,n+1):bs
37 37 | otherwise = bn : mix a bs
38 38
39 39 permBag :: Bag a -> [[a]]
40 40 permBag [] = [[]]
41 41 permBag bs = concatMap (\(f,cs) -> map (f:) $ permBag cs) . oneOfEach $ bs
42 42 where
43 43 oneOfEach [] = []
44 44 oneOfEach (an@(a,n):bs) =
45 45 let bs' = if n == 1 then bs else (a,n-1):bs
46 46 in (a,bs') : mapSnd (an:) (oneOfEach bs)
47
47
48 48 apSnd f (a,b) = (a, f b)
49 49 mapSnd = map . apSnd
50 50 </textarea></form>
51 51
52 52 <script>
53 53 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
54 54 lineNumbers: true,
55 55 matchBrackets: true,
56 56 theme: "elegant"
57 57 });
58 58 </script>
59 59
60 60 <p><strong>MIME types defined:</strong> <code>text/x-haskell</code>.</p>
61 61 </body>
62 62 </html>
@@ -1,90 +1,90 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: Haxe mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="haxe.js"></script>
9 9 <link rel="stylesheet" href="../../doc/docs.css">
10 10 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
11 11 </head>
12 12 <body>
13 13 <h1>CodeMirror: Haxe mode</h1>
14 14
15 15 <div><textarea id="code" name="code">
16 16 import one.two.Three;
17 17
18 18 @attr("test")
19 19 class Foo&lt;T&gt; extends Three
20 20 {
21 public function new()
22 {
23 noFoo = 12;
24 }
25
26 public static inline function doFoo(obj:{k:Int, l:Float}):Int
27 {
28 for(i in 0...10)
29 {
30 obj.k++;
31 trace(i);
32 var var1 = new Array();
33 if(var1.length > 1)
34 throw "Error";
35 }
36 // The following line should not be colored, the variable is scoped out
37 var1;
38 /* Multi line
39 * Comment test
40 */
41 return obj.k;
42 }
43 private function bar():Void
44 {
45 #if flash
46 var t1:String = "1.21";
47 #end
48 try {
49 doFoo({k:3, l:1.2});
50 }
51 catch (e : String) {
52 trace(e);
53 }
54 var t2:Float = cast(3.2);
55 var t3:haxe.Timer = new haxe.Timer();
56 var t4 = {k:Std.int(t2), l:Std.parseFloat(t1)};
57 var t5 = ~/123+.*$/i;
58 doFoo(t4);
59 untyped t1 = 4;
60 bob = new Foo&lt;Int&gt;
61 }
62 public var okFoo(default, never):Float;
63 var noFoo(getFoo, null):Int;
64 function getFoo():Int {
65 return noFoo;
66 }
67
68 public var three:Int;
21 public function new()
22 {
23 noFoo = 12;
24 }
25
26 public static inline function doFoo(obj:{k:Int, l:Float}):Int
27 {
28 for(i in 0...10)
29 {
30 obj.k++;
31 trace(i);
32 var var1 = new Array();
33 if(var1.length > 1)
34 throw "Error";
35 }
36 // The following line should not be colored, the variable is scoped out
37 var1;
38 /* Multi line
39 * Comment test
40 */
41 return obj.k;
42 }
43 private function bar():Void
44 {
45 #if flash
46 var t1:String = "1.21";
47 #end
48 try {
49 doFoo({k:3, l:1.2});
50 }
51 catch (e : String) {
52 trace(e);
53 }
54 var t2:Float = cast(3.2);
55 var t3:haxe.Timer = new haxe.Timer();
56 var t4 = {k:Std.int(t2), l:Std.parseFloat(t1)};
57 var t5 = ~/123+.*$/i;
58 doFoo(t4);
59 untyped t1 = 4;
60 bob = new Foo&lt;Int&gt;
61 }
62 public var okFoo(default, never):Float;
63 var noFoo(getFoo, null):Int;
64 function getFoo():Int {
65 return noFoo;
66 }
67
68 public var three:Int;
69 69 }
70 70 enum Color
71 71 {
72 red;
73 green;
74 blue;
75 grey( v : Int );
76 rgb (r:Int,g:Int,b:Int);
72 red;
73 green;
74 blue;
75 grey( v : Int );
76 rgb (r:Int,g:Int,b:Int);
77 77 }
78 78 </textarea></div>
79 79
80 80 <script>
81 81 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
82 82 lineNumbers: true,
83 83 indentUnit: 4,
84 84 indentWithTabs: true
85 85 });
86 86 </script>
87 87
88 88 <p><strong>MIME types defined:</strong> <code>text/x-haxe</code>.</p>
89 89 </body>
90 90 </html>
@@ -1,49 +1,49 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: Html Embedded Scripts mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="../xml/xml.js"></script>
9 9 <script src="../javascript/javascript.js"></script>
10 10 <script src="../css/css.js"></script>
11 11 <script src="../htmlmixed/htmlmixed.js"></script>
12 12 <script src="htmlembedded.js"></script>
13 13 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
14 14 <link rel="stylesheet" href="../../doc/docs.css">
15 15 </head>
16 16 <body>
17 17 <h1>CodeMirror: Html Embedded Scripts mode</h1>
18 18
19 19 <form><textarea id="code" name="code">
20 20 <%
21 21 function hello(who) {
22 return "Hello " + who;
22 return "Hello " + who;
23 23 }
24 24 %>
25 25 This is an example of EJS (embedded javascript)
26 26 <p>The program says <%= hello("world") %>.</p>
27 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 29 </script>
30 30 </textarea></form>
31 31
32 32 <script>
33 33 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
34 34 lineNumbers: true,
35 35 mode: "application/x-ejs",
36 36 indentUnit: 4,
37 37 indentWithTabs: true,
38 38 enterMode: "keep",
39 39 tabMode: "shift"
40 40 });
41 41 </script>
42 42
43 43 <p>Mode for html embedded scripts like JSP and ASP.NET. Depends on HtmlMixed which in turn depends on
44 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 47 <code>application/x-ejs</code> (Embedded Javascript), <code>application/x-jsp</code> (JavaServer Pages)</p>
48 48 </body>
49 49 </html>
@@ -1,32 +1,32 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: HTTP mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="http.js"></script>
9 9 <link rel="stylesheet" href="../../doc/docs.css">
10 10 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
11 11 </head>
12 12 <body>
13 13 <h1>CodeMirror: HTTP mode</h1>
14 14
15 15 <div><textarea id="code" name="code">
16 16 POST /somewhere HTTP/1.1
17 17 Host: example.com
18 18 If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT
19 19 Content-Type: application/x-www-form-urlencoded;
20 charset=utf-8
20 charset=utf-8
21 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 23 This is the request body!
24 24 </textarea></div>
25 25
26 26 <script>
27 27 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
28 28 </script>
29 29
30 30 <p><strong>MIME types defined:</strong> <code>message/http</code>.</p>
31 31 </body>
32 32 </html>
@@ -1,48 +1,48 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: TypeScript mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="javascript.js"></script>
9 9 <link rel="stylesheet" href="../../doc/docs.css">
10 10 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
11 11 </head>
12 12 <body>
13 13 <h1>CodeMirror: TypeScript mode</h1>
14 14
15 15 <div><textarea id="code" name="code">
16 16 class Greeter {
17 greeting: string;
18 constructor (message: string) {
19 this.greeting = message;
20 }
21 greet() {
22 return "Hello, " + this.greeting;
23 }
24 }
17 greeting: string;
18 constructor (message: string) {
19 this.greeting = message;
20 }
21 greet() {
22 return "Hello, " + this.greeting;
23 }
24 }
25 25
26 26 var greeter = new Greeter("world");
27 27
28 28 var button = document.createElement('button')
29 29 button.innerText = "Say Hello"
30 30 button.onclick = function() {
31 alert(greeter.greet())
31 alert(greeter.greet())
32 32 }
33 33
34 34 document.body.appendChild(button)
35 35
36 36 </textarea></div>
37 37
38 38 <script>
39 39 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
40 40 lineNumbers: true,
41 41 matchBrackets: true,
42 42 mode: "text/typescript"
43 43 });
44 44 </script>
45 45
46 46 <p>This is a specialization of the <a href="index.html">JavaScript mode</a>.</p>
47 47 </body>
48 48 </html>
@@ -1,741 +1,741 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: LESS mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="../../addon/edit/matchbrackets.js"></script>
9 9 <script src="less.js"></script>
10 10 <style>.CodeMirror {background: #f8f8f8; border: 1px solid #ddd; font-size:12px; height: 400px}</style>
11 11 <link rel="stylesheet" href="../../doc/docs.css">
12 12 <link rel="stylesheet" href="../../theme/lesser-dark.css">
13 13 </head>
14 14 <body>
15 15 <h1>CodeMirror: LESS mode</h1>
16 16 <form><textarea id="code" name="code">@media screen and (device-aspect-ratio: 16/9) { … }
17 17 @media screen and (device-aspect-ratio: 32/18) { … }
18 18 @media screen and (device-aspect-ratio: 1280/720) { … }
19 19 @media screen and (device-aspect-ratio: 2560/1440) { … }
20 20
21 21 html:lang(fr-be)
22 22 html:lang(de)
23 23 :lang(fr-be) > q
24 24 :lang(de) > q
25 25
26 26 tr:nth-child(2n+1) /* represents every odd row of an HTML table */
27 27 tr:nth-child(odd) /* same */
28 28 tr:nth-child(2n+0) /* represents every even row of an HTML table */
29 29 tr:nth-child(even) /* same */
30 30
31 31 /* Alternate paragraph colours in CSS */
32 32 p:nth-child(4n+1) { color: navy; }
33 33 p:nth-child(4n+2) { color: green; }
34 34 p:nth-child(4n+3) { color: maroon; }
35 35 p:nth-child(4n+4) { color: purple; }
36 36
37 37 :nth-child(10n-1) /* represents the 9th, 19th, 29th, etc, element */
38 38 :nth-child(10n+9) /* Same */
39 39 :nth-child(10n+-1) /* Syntactically invalid, and would be ignored */
40 40
41 41 :nth-child( 3n + 1 )
42 42 :nth-child( +3n - 2 )
43 43 :nth-child( -n+ 6)
44 44 :nth-child( +6 )
45 45
46 46 html|tr:nth-child(-n+6) /* represents the 6 first rows of XHTML tables */
47 47
48 48 img:nth-of-type(2n+1) { float: right; }
49 49 img:nth-of-type(2n) { float: left; }
50 50
51 51 body > h2:nth-of-type(n+2):nth-last-of-type(n+2)
52 52 body > h2:not(:first-of-type):not(:last-of-type)
53 53
54 54 html|*:not(:link):not(:visited)
55 55 *|*:not(:hover)
56 56 p::first-line { text-transform: uppercase }
57 57
58 58 p { color: red; font-size: 12pt }
59 59 p::first-letter { color: green; font-size: 200% }
60 60 p::first-line { color: blue }
61 61
62 62 p { line-height: 1.1 }
63 63 p::first-letter { font-size: 3em; font-weight: normal }
64 64 span { font-weight: bold }
65 65
66 66 * /* a=0 b=0 c=0 -> specificity = 0 */
67 67 LI /* a=0 b=0 c=1 -> specificity = 1 */
68 68 UL LI /* a=0 b=0 c=2 -> specificity = 2 */
69 69 UL OL+LI /* a=0 b=0 c=3 -> specificity = 3 */
70 70 H1 + *[REL=up] /* a=0 b=1 c=1 -> specificity = 11 */
71 71 UL OL LI.red /* a=0 b=1 c=3 -> specificity = 13 */
72 72 LI.red.level /* a=0 b=2 c=1 -> specificity = 21 */
73 73 #x34y /* a=1 b=0 c=0 -> specificity = 100 */
74 74 #s12:not(FOO) /* a=1 b=0 c=1 -> specificity = 101 */
75 75
76 76 @namespace foo url(http://www.example.com);
77 77 foo|h1 { color: blue } /* first rule */
78 78 foo|* { color: yellow } /* second rule */
79 79 |h1 { color: red } /* ...*/
80 80 *|h1 { color: green }
81 81 h1 { color: green }
82 82
83 83 span[hello="Ocean"][goodbye="Land"]
84 84
85 85 a[rel~="copyright"] { ... }
86 86 a[href="http://www.w3.org/"] { ... }
87 87
88 88 DIALOGUE[character=romeo]
89 89 DIALOGUE[character=juliet]
90 90
91 91 [att^=val]
92 92 [att$=val]
93 93 [att*=val]
94 94
95 95 @namespace foo "http://www.example.com";
96 96 [foo|att=val] { color: blue }
97 97 [*|att] { color: yellow }
98 98 [|att] { color: green }
99 99 [att] { color: green }
100 100
101 101
102 102 *:target { color : red }
103 103 *:target::before { content : url(target.png) }
104 104
105 105 E[foo]{
106 106 padding:65px;
107 107 }
108 108 E[foo] ~ F{
109 109 padding:65px;
110 110 }
111 111 E#myid{
112 112 padding:65px;
113 113 }
114 114 input[type="search"]::-webkit-search-decoration,
115 115 input[type="search"]::-webkit-search-cancel-button {
116 116 -webkit-appearance: none; // Inner-padding issues in Chrome OSX, Safari 5
117 117 }
118 118 button::-moz-focus-inner,
119 119 input::-moz-focus-inner { // Inner padding and border oddities in FF3/4
120 120 padding: 0;
121 121 border: 0;
122 122 }
123 123 .btn {
124 124 // reset here as of 2.0.3 due to Recess property order
125 125 border-color: #ccc;
126 126 border-color: rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);
127 127 }
128 128 fieldset span button, fieldset span input[type="file"] {
129 129 font-size:12px;
130 font-family:Arial, Helvetica, sans-serif;
130 font-family:Arial, Helvetica, sans-serif;
131 131 }
132 132 .el tr:nth-child(even):last-child td:first-child{
133 -moz-border-radius-bottomleft:3px;
134 -webkit-border-bottom-left-radius:3px;
135 border-bottom-left-radius:3px;
133 -moz-border-radius-bottomleft:3px;
134 -webkit-border-bottom-left-radius:3px;
135 border-bottom-left-radius:3px;
136 136 }
137 137
138 138 /* Some LESS code */
139 139
140 140 button {
141 141 width: 32px;
142 142 height: 32px;
143 143 border: 0;
144 144 margin: 4px;
145 145 cursor: pointer;
146 146 }
147 147 button.icon-plus { background: url(http://dahlström.net/tmp/sharp-icons/svg-icon-target.svg#plus) no-repeat; }
148 148 button.icon-chart { background: url(http://dahlström.net/tmp/sharp-icons/svg-icon-target.svg#chart) no-repeat; }
149 149
150 150 button:hover { background-color: #999; }
151 151 button:active { background-color: #666; }
152 152
153 153 @test_a: #eeeQQQ;//this is not a valid hex value and thus parsed as an element id
154 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 156 #eee aaa .box
157 157 {
158 158 #test bbb {
159 159 width: 500px;
160 160 height: 250px;
161 161 background-image: url(dir/output/sheep.png), url( betweengrassandsky.png );
162 162 background-position: center bottom, left top;
163 163 background-repeat: no-repeat;
164 164 }
165 165 }
166 166
167 167 @base: #f938ab;
168 168
169 169 .box-shadow(@style, @c) when (iscolor(@c)) {
170 170 box-shadow: @style @c;
171 171 -webkit-box-shadow: @style @c;
172 172 -moz-box-shadow: @style @c;
173 173 }
174 174 .box-shadow(@style, @alpha: 50%) when (isnumber(@alpha)) {
175 175 .box-shadow(@style, rgba(0, 0, 0, @alpha));
176 176 }
177 177
178 178 @color: #4D926F;
179 179
180 180 #header {
181 181 color: @color;
182 182 color: #000000;
183 183 }
184 184 h2 {
185 185 color: @color;
186 186 }
187 187
188 188 .rounded-corners (@radius: 5px) {
189 189 border-radius: @radius;
190 190 -webkit-border-radius: @radius;
191 191 -moz-border-radius: @radius;
192 192 }
193 193
194 194 #header {
195 195 .rounded-corners;
196 196 }
197 197 #footer {
198 198 .rounded-corners(10px);
199 199 }
200 200
201 201 .box-shadow (@x: 0, @y: 0, @blur: 1px, @alpha) {
202 202 @val: @x @y @blur rgba(0, 0, 0, @alpha);
203 203
204 204 box-shadow: @val;
205 205 -webkit-box-shadow: @val;
206 206 -moz-box-shadow: @val;
207 207 }
208 208 .box { @base: #f938ab;
209 209 color: saturate(@base, 5%);
210 210 border-color: lighten(@base, 30%);
211 211 div { .box-shadow(0, 0, 5px, 0.4) }
212 212 }
213 213
214 214 @import url("something.css");
215 215
216 216 @light-blue: hsl(190, 50%, 65%);
217 217 @light-yellow: desaturate(#fefec8, 10%);
218 218 @dark-yellow: desaturate(darken(@light-yellow, 10%), 40%);
219 219 @darkest: hsl(20, 0%, 15%);
220 220 @dark: hsl(190, 20%, 30%);
221 221 @medium: hsl(10, 60%, 30%);
222 222 @light: hsl(90, 40%, 20%);
223 223 @lightest: hsl(90, 20%, 90%);
224 224 @highlight: hsl(80, 50%, 90%);
225 225 @blue: hsl(210, 60%, 20%);
226 226 @alpha-blue: hsla(210, 60%, 40%, 0.5);
227 227
228 228 .box-shadow (@x, @y, @blur, @alpha) {
229 229 @value: @x @y @blur rgba(0, 0, 0, @alpha);
230 230 box-shadow: @value;
231 231 -moz-box-shadow: @value;
232 232 -webkit-box-shadow: @value;
233 233 }
234 234 .border-radius (@radius) {
235 235 border-radius: @radius;
236 236 -moz-border-radius: @radius;
237 237 -webkit-border-radius: @radius;
238 238 }
239 239
240 240 .border-radius (@radius, bottom) {
241 241 border-top-right-radius: 0;
242 242 border-top-left-radius: 0;
243 243 -moz-border-top-right-radius: 0;
244 244 -moz-border-top-left-radius: 0;
245 245 -webkit-border-top-left-radius: 0;
246 246 -webkit-border-top-right-radius: 0;
247 247 }
248 248 .border-radius (@radius, right) {
249 249 border-bottom-left-radius: 0;
250 250 border-top-left-radius: 0;
251 251 -moz-border-bottom-left-radius: 0;
252 252 -moz-border-top-left-radius: 0;
253 253 -webkit-border-bottom-left-radius: 0;
254 254 -webkit-border-top-left-radius: 0;
255 255 }
256 256 .box-shadow-inset (@x, @y, @blur, @color) {
257 257 box-shadow: @x @y @blur @color inset;
258 258 -moz-box-shadow: @x @y @blur @color inset;
259 259 -webkit-box-shadow: @x @y @blur @color inset;
260 260 }
261 261 .code () {
262 262 font-family: 'Bitstream Vera Sans Mono',
263 263 'DejaVu Sans Mono',
264 264 'Monaco',
265 265 Courier,
266 266 monospace !important;
267 267 }
268 268 .wrap () {
269 269 text-wrap: wrap;
270 270 white-space: pre-wrap; /* css-3 */
271 271 white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
272 272 white-space: -pre-wrap; /* Opera 4-6 */
273 273 white-space: -o-pre-wrap; /* Opera 7 */
274 274 word-wrap: break-word; /* Internet Explorer 5.5+ */
275 275 }
276 276
277 277 html { margin: 0 }
278 278 body {
279 279 background-color: @darkest;
280 280 margin: 0 auto;
281 281 font-family: Arial, sans-serif;
282 282 font-size: 100%;
283 283 overflow-x: hidden;
284 284 }
285 285 nav, header, footer, section, article {
286 286 display: block;
287 287 }
288 288 a {
289 289 color: #b83000;
290 290 }
291 291 h1 a {
292 292 color: black;
293 293 text-decoration: none;
294 294 }
295 295 a:hover {
296 296 text-decoration: underline;
297 297 }
298 298 h1, h2, h3, h4 {
299 299 margin: 0;
300 300 font-weight: normal;
301 301 }
302 302 ul, li {
303 303 list-style-type: none;
304 304 }
305 305 code { .code; }
306 306 code {
307 307 .string, .regexp { color: @dark }
308 308 .keyword { font-weight: bold }
309 309 .comment { color: rgba(0, 0, 0, 0.5) }
310 310 .number { color: @blue }
311 311 .class, .special { color: rgba(0, 50, 100, 0.8) }
312 312 }
313 313 pre {
314 314 padding: 0 30px;
315 315 .wrap;
316 316 }
317 317 blockquote {
318 318 font-style: italic;
319 319 }
320 320 body > footer {
321 321 text-align: left;
322 322 margin-left: 10px;
323 323 font-style: italic;
324 324 font-size: 18px;
325 325 color: #888;
326 326 }
327 327
328 328 #logo {
329 329 margin-top: 30px;
330 330 margin-bottom: 30px;
331 331 display: block;
332 332 width: 199px;
333 333 height: 81px;
334 334 background: url(/images/logo.png) no-repeat;
335 335 }
336 336 nav {
337 337 margin-left: 15px;
338 338 }
339 339 nav a, #dropdown li {
340 340 display: inline-block;
341 341 color: white;
342 342 line-height: 42px;
343 343 margin: 0;
344 344 padding: 0px 15px;
345 345 text-shadow: -1px -1px 1px rgba(0, 0, 0, 0.5);
346 346 text-decoration: none;
347 347 border: 2px solid transparent;
348 348 border-width: 0 2px;
349 349 &:hover {
350 .dark-red;
350 .dark-red;
351 351 text-decoration: none;
352 352 }
353 353 }
354 354 .dark-red {
355 355 @red: @medium;
356 356 border: 2px solid darken(@red, 25%);
357 357 border-left-color: darken(@red, 15%);
358 358 border-right-color: darken(@red, 15%);
359 359 border-bottom: 0;
360 360 border-top: 0;
361 361 background-color: darken(@red, 10%);
362 362 }
363 363
364 364 .content {
365 365 margin: 0 auto;
366 366 width: 980px;
367 367 }
368 368
369 369 #menu {
370 370 position: absolute;
371 371 width: 100%;
372 372 z-index: 3;
373 373 clear: both;
374 374 display: block;
375 375 background-color: @blue;
376 376 height: 42px;
377 377 border-top: 2px solid lighten(@alpha-blue, 20%);
378 378 border-bottom: 2px solid darken(@alpha-blue, 25%);
379 379 .box-shadow(0, 1px, 8px, 0.6);
380 380 -moz-box-shadow: 0 0 0 #000; // Because firefox sucks.
381 381
382 382 &.docked {
383 383 background-color: hsla(210, 60%, 40%, 0.4);
384 384 }
385 385 &:hover {
386 386 background-color: @blue;
387 387 }
388 388
389 389 #dropdown {
390 390 margin: 0 0 0 117px;
391 391 padding: 0;
392 392 padding-top: 5px;
393 393 display: none;
394 394 width: 190px;
395 395 border-top: 2px solid @medium;
396 396 color: @highlight;
397 397 border: 2px solid darken(@medium, 25%);
398 398 border-left-color: darken(@medium, 15%);
399 399 border-right-color: darken(@medium, 15%);
400 400 border-top-width: 0;
401 401 background-color: darken(@medium, 10%);
402 402 ul {
403 padding: 0px;
403 padding: 0px;
404 404 }
405 405 li {
406 406 font-size: 14px;
407 407 display: block;
408 408 text-align: left;
409 409 padding: 0;
410 410 border: 0;
411 411 a {
412 412 display: block;
413 padding: 0px 15px;
413 padding: 0px 15px;
414 414 text-decoration: none;
415 color: white;
415 color: white;
416 416 &:hover {
417 417 background-color: darken(@medium, 15%);
418 418 text-decoration: none;
419 419 }
420 420 }
421 421 }
422 422 .border-radius(5px, bottom);
423 423 .box-shadow(0, 6px, 8px, 0.5);
424 424 }
425 425 }
426 426
427 427 #main {
428 428 margin: 0 auto;
429 429 width: 100%;
430 430 background-color: @light-blue;
431 431 border-top: 8px solid darken(@light-blue, 5%);
432 432
433 433 #intro {
434 434 background-color: lighten(@light-blue, 25%);
435 435 float: left;
436 436 margin-top: -8px;
437 437 margin-right: 5px;
438 438
439 439 height: 380px;
440 440 position: relative;
441 441 z-index: 2;
442 442 font-family: 'Droid Serif', 'Georgia';
443 443 width: 395px;
444 444 padding: 45px 20px 23px 30px;
445 445 border: 2px dashed darken(@light-blue, 10%);
446 446 .box-shadow(1px, 0px, 6px, 0.5);
447 447 border-bottom: 0;
448 448 border-top: 0;
449 449 #download { color: transparent; border: 0; float: left; display: inline-block; margin: 15px 0 15px -5px; }
450 450 #download img { display: inline-block}
451 451 #download-info {
452 452 code {
453 font-size: 13px;
453 font-size: 13px;
454 454 }
455 455 color: @blue + #333; display: inline; float: left; margin: 36px 0 0 15px }
456 456 }
457 457 h2 {
458 458 span {
459 color: @medium;
459 color: @medium;
460 460 }
461 461 color: @blue;
462 462 margin: 20px 0;
463 463 font-size: 24px;
464 464 line-height: 1.2em;
465 465 }
466 466 h3 {
467 467 color: @blue;
468 468 line-height: 1.4em;
469 469 margin: 30px 0 15px 0;
470 470 font-size: 1em;
471 471 text-shadow: 0px 0px 0px @lightest;
472 472 span { color: @medium }
473 473 }
474 474 #example {
475 475 p {
476 476 font-size: 18px;
477 477 color: @blue;
478 478 font-weight: bold;
479 479 text-shadow: 0px 1px 1px @lightest;
480 480 }
481 481 pre {
482 482 margin: 0;
483 483 text-shadow: 0 -1px 1px @darkest;
484 484 margin-top: 20px;
485 485 background-color: desaturate(@darkest, 8%);
486 486 border: 0;
487 487 width: 450px;
488 488 color: lighten(@lightest, 2%);
489 489 background-repeat: repeat;
490 490 padding: 15px;
491 491 border: 1px dashed @lightest;
492 492 line-height: 15px;
493 493 .box-shadow(0, 0px, 15px, 0.5);
494 494 .code;
495 495 .border-radius(2px);
496 496 code .attribute { color: hsl(40, 50%, 70%) }
497 497 code .variable { color: hsl(120, 10%, 50%) }
498 498 code .element { color: hsl(170, 20%, 50%) }
499 499
500 500 code .string, .regexp { color: hsl(75, 50%, 65%) }
501 501 code .class { color: hsl(40, 40%, 60%); font-weight: normal }
502 502 code .id { color: hsl(50, 40%, 60%); font-weight: normal }
503 503 code .comment { color: rgba(255, 255, 255, 0.2) }
504 504 code .number, .color { color: hsl(10, 40%, 50%) }
505 505 code .class, code .mixin, .special { color: hsl(190, 20%, 50%) }
506 506 #time { color: #aaa }
507 507 }
508 508 float: right;
509 509 font-size: 12px;
510 510 margin: 0;
511 511 margin-top: 15px;
512 512 padding: 0;
513 513 width: 500px;
514 514 }
515 515 }
516 516
517 517
518 518 .page {
519 519 .content {
520 520 width: 870px;
521 521 padding: 45px;
522 522 }
523 523 margin: 0 auto;
524 524 font-family: 'Georgia', serif;
525 525 font-size: 18px;
526 526 line-height: 26px;
527 527 padding: 0 60px;
528 528 code {
529 font-size: 16px;
529 font-size: 16px;
530 530 }
531 531 pre {
532 532 border-width: 1px;
533 533 border-style: dashed;
534 534 padding: 15px;
535 535 margin: 15px 0;
536 536 }
537 537 h1 {
538 538 text-align: left;
539 539 font-size: 40px;
540 540 margin-top: 15px;
541 541 margin-bottom: 35px;
542 542 }
543 543 p + h1 { margin-top: 60px }
544 544 h2, h3 {
545 545 margin: 30px 0 15px 0;
546 546 }
547 547 p + h2, pre + h2, code + h2 {
548 548 border-top: 6px solid rgba(255, 255, 255, 0.1);
549 549 padding-top: 30px;
550 550 }
551 551 h3 {
552 552 margin: 15px 0;
553 553 }
554 554 }
555 555
556 556
557 557 #docs {
558 558 @bg: lighten(@light-blue, 5%);
559 559 border-top: 2px solid lighten(@bg, 5%);
560 560 color: @blue;
561 561 background-color: @light-blue;
562 562 .box-shadow(0, -2px, 5px, 0.2);
563 563
564 564 h1 {
565 565 font-family: 'Droid Serif', 'Georgia', serif;
566 566 padding-top: 30px;
567 567 padding-left: 45px;
568 568 font-size: 44px;
569 569 text-align: left;
570 570 margin: 30px 0 !important;
571 571 text-shadow: 0px 1px 1px @lightest;
572 572 font-weight: bold;
573 573 }
574 574 .content {
575 575 clear: both;
576 576 border-color: transparent;
577 577 background-color: lighten(@light-blue, 25%);
578 578 .box-shadow(0, 5px, 5px, 0.4);
579 579 }
580 580 pre {
581 581 @background: lighten(@bg, 30%);
582 582 color: lighten(@blue, 10%);
583 583 background-color: @background;
584 584 border-color: lighten(@light-blue, 25%);
585 585 border-width: 2px;
586 586 code .attribute { color: hsl(40, 50%, 30%) }
587 587 code .variable { color: hsl(120, 10%, 30%) }
588 588 code .element { color: hsl(170, 20%, 30%) }
589 589
590 590 code .string, .regexp { color: hsl(75, 50%, 35%) }
591 591 code .class { color: hsl(40, 40%, 30%); font-weight: normal }
592 592 code .id { color: hsl(50, 40%, 30%); font-weight: normal }
593 593 code .comment { color: rgba(0, 0, 0, 0.4) }
594 594 code .number, .color { color: hsl(10, 40%, 30%) }
595 595 code .class, code .mixin, .special { color: hsl(190, 20%, 30%) }
596 596 }
597 597 pre code { font-size: 15px }
598 598 p + h2, pre + h2, code + h2 { border-top-color: rgba(0, 0, 0, 0.1) }
599 599 }
600 600
601 601 td {
602 padding-right: 30px;
602 padding-right: 30px;
603 603 }
604 604 #synopsis {
605 605 .box-shadow(0, 5px, 5px, 0.2);
606 606 }
607 607 #synopsis, #about {
608 608 h2 {
609 font-size: 30px;
609 font-size: 30px;
610 610 padding: 10px 0;
611 611 }
612 612 h1 + h2 {
613 margin-top: 15px;
613 margin-top: 15px;
614 614 }
615 615 h3 { font-size: 22px }
616 616
617 617 .code-example {
618 618 border-spacing: 0;
619 619 border-width: 1px;
620 620 border-style: dashed;
621 621 padding: 0;
622 622 pre { border: 0; margin: 0 }
623 623 td {
624 624 border: 0;
625 625 margin: 0;
626 626 background-color: desaturate(darken(@darkest, 5%), 20%);
627 627 vertical-align: top;
628 628 padding: 0;
629 629 }
630 630 tr { padding: 0 }
631 631 }
632 632 .css-output {
633 633 td {
634 border-left: 0;
634 border-left: 0;
635 635 }
636 636 }
637 637 .less-example {
638 638 //border-right: 1px dotted rgba(255, 255, 255, 0.5) !important;
639 639 }
640 640 .css-output, .less-example {
641 641 width: 390px;
642 642 }
643 643 pre {
644 644 padding: 20px;
645 645 line-height: 20px;
646 646 font-size: 14px;
647 647 }
648 648 }
649 649 #about, #synopsis, #guide {
650 650 a {
651 651 text-decoration: none;
652 652 color: @light-yellow;
653 653 border-bottom: 1px dashed rgba(255, 255, 255, 0.2);
654 654 &:hover {
655 655 text-decoration: none;
656 656 border-bottom: 1px dashed @light-yellow;
657 657 }
658 658 }
659 659 @bg: desaturate(darken(@darkest, 5%), 20%);
660 660 text-shadow: 0 -1px 1px lighten(@bg, 5%);
661 661 color: @highlight;
662 662 background-color: @bg;
663 663 .content {
664 664 background-color: desaturate(@darkest, 20%);
665 665 clear: both;
666 666 .box-shadow(0, 5px, 5px, 0.4);
667 667 }
668 668 h1, h2, h3 {
669 669 color: @dark-yellow;
670 670 }
671 671 pre {
672 672 code .attribute { color: hsl(40, 50%, 70%) }
673 673 code .variable { color: hsl(120, 10%, 50%) }
674 674 code .element { color: hsl(170, 20%, 50%) }
675 675
676 676 code .string, .regexp { color: hsl(75, 50%, 65%) }
677 677 code .class { color: hsl(40, 40%, 60%); font-weight: normal }
678 678 code .id { color: hsl(50, 40%, 60%); font-weight: normal }
679 679 code .comment { color: rgba(255, 255, 255, 0.2) }
680 680 code .number, .color { color: hsl(10, 40%, 50%) }
681 681 code .class, code .mixin, .special { color: hsl(190, 20%, 50%) }
682 682 background-color: @bg;
683 683 border-color: darken(@light-yellow, 5%);
684 684 }
685 685 code {
686 686 color: darken(@dark-yellow, 5%);
687 687 .string, .regexp { color: desaturate(@light-blue, 15%) }
688 688 .keyword { color: hsl(40, 40%, 60%); font-weight: normal }
689 689 .comment { color: rgba(255, 255, 255, 0.2) }
690 690 .number { color: lighten(@blue, 10%) }
691 691 .class, .special { color: hsl(190, 20%, 50%) }
692 692 }
693 693 }
694 694 #guide {
695 695 background-color: @darkest;
696 696 .content {
697 697 background-color: transparent;
698 698 }
699 699
700 700 }
701 701
702 702 #about {
703 703 background-color: @darkest !important;
704 704 .content {
705 705 background-color: desaturate(lighten(@darkest, 3%), 5%);
706 706 }
707 707 }
708 708 #synopsis {
709 709 background-color: desaturate(lighten(@darkest, 3%), 5%) !important;
710 710 .content {
711 711 background-color: desaturate(lighten(@darkest, 3%), 5%);
712 712 }
713 713 pre {}
714 714 }
715 715 #synopsis, #guide {
716 716 .content {
717 717 .box-shadow(0, 0px, 0px, 0.0);
718 718 }
719 719 }
720 720 #about footer {
721 721 margin-top: 30px;
722 722 padding-top: 30px;
723 723 border-top: 6px solid rgba(0, 0, 0, 0.1);
724 724 text-align: center;
725 725 font-size: 16px;
726 726 color: rgba(255, 255, 255, 0.35);
727 727 #copy { font-size: 12px }
728 728 text-shadow: -1px -1px 1px rgba(0, 0, 0, 0.02);
729 729 }
730 730 </textarea></form>
731 731 <script>
732 732 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
733 733 theme: "lesser-dark",
734 734 lineNumbers : true,
735 735 matchBrackets : true
736 736 });
737 737 </script>
738 738
739 739 <p><strong>MIME types defined:</strong> <code>text/x-less</code>, <code>text/css</code> (if not previously defined).</p>
740 740 </body>
741 741 </html>
@@ -1,74 +1,74 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: Lua mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../addon/edit/matchbrackets.js"></script>
8 8 <script src="../../lib/codemirror.js"></script>
9 9 <script src="lua.js"></script>
10 10 <link rel="stylesheet" href="../../theme/neat.css">
11 11 <style>.CodeMirror {border: 1px solid black;}</style>
12 12 <link rel="stylesheet" href="../../doc/docs.css">
13 13 </head>
14 14 <body>
15 15 <h1>CodeMirror: Lua mode</h1>
16 16 <form><textarea id="code" name="code">
17 17 --[[
18 18 example useless code to show lua syntax highlighting
19 19 this is multiline comment
20 20 ]]
21 21
22 22 function blahblahblah(x)
23 23
24 24 local table = {
25 25 "asd" = 123,
26 "x" = 0.34,
26 "x" = 0.34,
27 27 }
28 28 if x ~= 3 then
29 29 print( x )
30 30 elseif x == "string"
31 31 my_custom_function( 0x34 )
32 32 else
33 33 unknown_function( "some string" )
34 34 end
35 35
36 36 --single line comment
37
37
38 38 end
39 39
40 40 function blablabla3()
41 41
42 42 for k,v in ipairs( table ) do
43 43 --abcde..
44 44 y=[=[
45 45 x=[[
46 46 x is a multi line string
47 47 ]]
48 48 but its definition is iside a highest level string!
49 49 ]=]
50 50 print(" \"\" ")
51 51
52 52 s = math.sin( x )
53 53 end
54 54
55 55 end
56 56 </textarea></form>
57 57 <script>
58 58 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
59 59 tabMode: "indent",
60 60 matchBrackets: true,
61 61 theme: "neat"
62 62 });
63 63 </script>
64 64
65 65 <p>Loosely based on Franciszek
66 66 Wawrzak's <a href="http://codemirror.net/1/contrib/lua">CodeMirror
67 67 1 mode</a>. One configuration parameter is
68 68 supported, <code>specials</code>, to which you can provide an
69 69 array of strings to have those identifiers highlighted with
70 70 the <code>lua-special</code> style.</p>
71 71 <p><strong>MIME types defined:</strong> <code>text/x-lua</code>.</p>
72 72
73 73 </body>
74 74 </html>
@@ -1,344 +1,344 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: Markdown mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="../../addon/edit/continuelist.js"></script>
9 9 <script src="../xml/xml.js"></script>
10 10 <script src="markdown.js"></script>
11 11 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
12 12 <link rel="stylesheet" href="../../doc/docs.css">
13 13 </head>
14 14 <body>
15 15 <h1>CodeMirror: Markdown mode</h1>
16 16
17 17 <!-- source: http://daringfireball.net/projects/markdown/basics.text -->
18 18 <form><textarea id="code" name="code">
19 19 Markdown: Basics
20 20 ================
21 21
22 22 &lt;ul id="ProjectSubmenu"&gt;
23 23 &lt;li&gt;&lt;a href="/projects/markdown/" title="Markdown Project Page"&gt;Main&lt;/a&gt;&lt;/li&gt;
24 24 &lt;li&gt;&lt;a class="selected" title="Markdown Basics"&gt;Basics&lt;/a&gt;&lt;/li&gt;
25 25 &lt;li&gt;&lt;a href="/projects/markdown/syntax" title="Markdown Syntax Documentation"&gt;Syntax&lt;/a&gt;&lt;/li&gt;
26 26 &lt;li&gt;&lt;a href="/projects/markdown/license" title="Pricing and License Information"&gt;License&lt;/a&gt;&lt;/li&gt;
27 27 &lt;li&gt;&lt;a href="/projects/markdown/dingus" title="Online Markdown Web Form"&gt;Dingus&lt;/a&gt;&lt;/li&gt;
28 28 &lt;/ul&gt;
29 29
30 30
31 31 Getting the Gist of Markdown's Formatting Syntax
32 32 ------------------------------------------------
33 33
34 34 This page offers a brief overview of what it's like to use Markdown.
35 35 The [syntax page] [s] provides complete, detailed documentation for
36 36 every feature, but Markdown should be very easy to pick up simply by
37 37 looking at a few examples of it in action. The examples on this page
38 38 are written in a before/after style, showing example syntax and the
39 39 HTML output produced by Markdown.
40 40
41 41 It's also helpful to simply try Markdown out; the [Dingus] [d] is a
42 42 web application that allows you type your own Markdown-formatted text
43 43 and translate it to XHTML.
44 44
45 45 **Note:** This document is itself written using Markdown; you
46 46 can [see the source for it by adding '.text' to the URL] [src].
47 47
48 48 [s]: /projects/markdown/syntax "Markdown Syntax"
49 49 [d]: /projects/markdown/dingus "Markdown Dingus"
50 50 [src]: /projects/markdown/basics.text
51 51
52 52
53 53 ## Paragraphs, Headers, Blockquotes ##
54 54
55 55 A paragraph is simply one or more consecutive lines of text, separated
56 56 by one or more blank lines. (A blank line is any line that looks like
57 57 a blank line -- a line containing nothing but spaces or tabs is
58 58 considered blank.) Normal paragraphs should not be indented with
59 59 spaces or tabs.
60 60
61 61 Markdown offers two styles of headers: *Setext* and *atx*.
62 62 Setext-style headers for `&lt;h1&gt;` and `&lt;h2&gt;` are created by
63 63 "underlining" with equal signs (`=`) and hyphens (`-`), respectively.
64 64 To create an atx-style header, you put 1-6 hash marks (`#`) at the
65 65 beginning of the line -- the number of hashes equals the resulting
66 66 HTML header level.
67 67
68 68 Blockquotes are indicated using email-style '`&gt;`' angle brackets.
69 69
70 70 Markdown:
71 71
72 72 A First Level Header
73 73 ====================
74
74
75 75 A Second Level Header
76 76 ---------------------
77 77
78 78 Now is the time for all good men to come to
79 79 the aid of their country. This is just a
80 80 regular paragraph.
81 81
82 82 The quick brown fox jumped over the lazy
83 83 dog's back.
84
84
85 85 ### Header 3
86 86
87 87 &gt; This is a blockquote.
88 &gt;
88 &gt;
89 89 &gt; This is the second paragraph in the blockquote.
90 90 &gt;
91 91 &gt; ## This is an H2 in a blockquote
92 92
93 93
94 94 Output:
95 95
96 96 &lt;h1&gt;A First Level Header&lt;/h1&gt;
97
97
98 98 &lt;h2&gt;A Second Level Header&lt;/h2&gt;
99
99
100 100 &lt;p&gt;Now is the time for all good men to come to
101 101 the aid of their country. This is just a
102 102 regular paragraph.&lt;/p&gt;
103
103
104 104 &lt;p&gt;The quick brown fox jumped over the lazy
105 105 dog's back.&lt;/p&gt;
106
106
107 107 &lt;h3&gt;Header 3&lt;/h3&gt;
108
108
109 109 &lt;blockquote&gt;
110 110 &lt;p&gt;This is a blockquote.&lt;/p&gt;
111
111
112 112 &lt;p&gt;This is the second paragraph in the blockquote.&lt;/p&gt;
113
113
114 114 &lt;h2&gt;This is an H2 in a blockquote&lt;/h2&gt;
115 115 &lt;/blockquote&gt;
116 116
117 117
118 118
119 119 ### Phrase Emphasis ###
120 120
121 121 Markdown uses asterisks and underscores to indicate spans of emphasis.
122 122
123 123 Markdown:
124 124
125 125 Some of these words *are emphasized*.
126 126 Some of these words _are emphasized also_.
127
127
128 128 Use two asterisks for **strong emphasis**.
129 129 Or, if you prefer, __use two underscores instead__.
130 130
131 131 Output:
132 132
133 133 &lt;p&gt;Some of these words &lt;em&gt;are emphasized&lt;/em&gt;.
134 134 Some of these words &lt;em&gt;are emphasized also&lt;/em&gt;.&lt;/p&gt;
135
135
136 136 &lt;p&gt;Use two asterisks for &lt;strong&gt;strong emphasis&lt;/strong&gt;.
137 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 141 ## Lists ##
142 142
143 143 Unordered (bulleted) lists use asterisks, pluses, and hyphens (`*`,
144 144 `+`, and `-`) as list markers. These three markers are
145 145 interchangable; this:
146 146
147 147 * Candy.
148 148 * Gum.
149 149 * Booze.
150 150
151 151 this:
152 152
153 153 + Candy.
154 154 + Gum.
155 155 + Booze.
156 156
157 157 and this:
158 158
159 159 - Candy.
160 160 - Gum.
161 161 - Booze.
162 162
163 163 all produce the same output:
164 164
165 165 &lt;ul&gt;
166 166 &lt;li&gt;Candy.&lt;/li&gt;
167 167 &lt;li&gt;Gum.&lt;/li&gt;
168 168 &lt;li&gt;Booze.&lt;/li&gt;
169 169 &lt;/ul&gt;
170 170
171 171 Ordered (numbered) lists use regular numbers, followed by periods, as
172 172 list markers:
173 173
174 174 1. Red
175 175 2. Green
176 176 3. Blue
177 177
178 178 Output:
179 179
180 180 &lt;ol&gt;
181 181 &lt;li&gt;Red&lt;/li&gt;
182 182 &lt;li&gt;Green&lt;/li&gt;
183 183 &lt;li&gt;Blue&lt;/li&gt;
184 184 &lt;/ol&gt;
185 185
186 186 If you put blank lines between items, you'll get `&lt;p&gt;` tags for the
187 187 list item text. You can create multi-paragraph list items by indenting
188 188 the paragraphs by 4 spaces or 1 tab:
189 189
190 190 * A list item.
191
191
192 192 With multiple paragraphs.
193 193
194 194 * Another item in the list.
195 195
196 196 Output:
197 197
198 198 &lt;ul&gt;
199 199 &lt;li&gt;&lt;p&gt;A list item.&lt;/p&gt;
200 200 &lt;p&gt;With multiple paragraphs.&lt;/p&gt;&lt;/li&gt;
201 201 &lt;li&gt;&lt;p&gt;Another item in the list.&lt;/p&gt;&lt;/li&gt;
202 202 &lt;/ul&gt;
203
203
204 204
205 205
206 206 ### Links ###
207 207
208 208 Markdown supports two styles for creating links: *inline* and
209 209 *reference*. With both styles, you use square brackets to delimit the
210 210 text you want to turn into a link.
211 211
212 212 Inline-style links use parentheses immediately after the link text.
213 213 For example:
214 214
215 215 This is an [example link](http://example.com/).
216 216
217 217 Output:
218 218
219 219 &lt;p&gt;This is an &lt;a href="http://example.com/"&gt;
220 220 example link&lt;/a&gt;.&lt;/p&gt;
221 221
222 222 Optionally, you may include a title attribute in the parentheses:
223 223
224 224 This is an [example link](http://example.com/ "With a Title").
225 225
226 226 Output:
227 227
228 228 &lt;p&gt;This is an &lt;a href="http://example.com/" title="With a Title"&gt;
229 229 example link&lt;/a&gt;.&lt;/p&gt;
230 230
231 231 Reference-style links allow you to refer to your links by names, which
232 232 you define elsewhere in your document:
233 233
234 234 I get 10 times more traffic from [Google][1] than from
235 235 [Yahoo][2] or [MSN][3].
236 236
237 237 [1]: http://google.com/ "Google"
238 238 [2]: http://search.yahoo.com/ "Yahoo Search"
239 239 [3]: http://search.msn.com/ "MSN Search"
240 240
241 241 Output:
242 242
243 243 &lt;p&gt;I get 10 times more traffic from &lt;a href="http://google.com/"
244 244 title="Google"&gt;Google&lt;/a&gt; than from &lt;a href="http://search.yahoo.com/"
245 245 title="Yahoo Search"&gt;Yahoo&lt;/a&gt; or &lt;a href="http://search.msn.com/"
246 246 title="MSN Search"&gt;MSN&lt;/a&gt;.&lt;/p&gt;
247 247
248 248 The title attribute is optional. Link names may contain letters,
249 249 numbers and spaces, but are *not* case sensitive:
250 250
251 251 I start my morning with a cup of coffee and
252 252 [The New York Times][NY Times].
253 253
254 254 [ny times]: http://www.nytimes.com/
255 255
256 256 Output:
257 257
258 258 &lt;p&gt;I start my morning with a cup of coffee and
259 259 &lt;a href="http://www.nytimes.com/"&gt;The New York Times&lt;/a&gt;.&lt;/p&gt;
260 260
261 261
262 262 ### Images ###
263 263
264 264 Image syntax is very much like link syntax.
265 265
266 266 Inline (titles are optional):
267 267
268 268 ![alt text](/path/to/img.jpg "Title")
269 269
270 270 Reference-style:
271 271
272 272 ![alt text][id]
273 273
274 274 [id]: /path/to/img.jpg "Title"
275 275
276 276 Both of the above examples produce the same output:
277 277
278 278 &lt;img src="/path/to/img.jpg" alt="alt text" title="Title" /&gt;
279 279
280 280
281 281
282 282 ### Code ###
283 283
284 284 In a regular paragraph, you can create code span by wrapping text in
285 285 backtick quotes. Any ampersands (`&amp;`) and angle brackets (`&lt;` or
286 286 `&gt;`) will automatically be translated into HTML entities. This makes
287 287 it easy to use Markdown to write about HTML example code:
288 288
289 289 I strongly recommend against using any `&lt;blink&gt;` tags.
290 290
291 291 I wish SmartyPants used named entities like `&amp;mdash;`
292 292 instead of decimal-encoded entites like `&amp;#8212;`.
293 293
294 294 Output:
295 295
296 296 &lt;p&gt;I strongly recommend against using any
297 297 &lt;code&gt;&amp;lt;blink&amp;gt;&lt;/code&gt; tags.&lt;/p&gt;
298
298
299 299 &lt;p&gt;I wish SmartyPants used named entities like
300 300 &lt;code&gt;&amp;amp;mdash;&lt;/code&gt; instead of decimal-encoded
301 301 entites like &lt;code&gt;&amp;amp;#8212;&lt;/code&gt;.&lt;/p&gt;
302 302
303 303
304 304 To specify an entire block of pre-formatted code, indent every line of
305 305 the block by 4 spaces or 1 tab. Just like with code spans, `&amp;`, `&lt;`,
306 306 and `&gt;` characters will be escaped automatically.
307 307
308 308 Markdown:
309 309
310 310 If you want your page to validate under XHTML 1.0 Strict,
311 311 you've got to put paragraph tags in your blockquotes:
312 312
313 313 &lt;blockquote&gt;
314 314 &lt;p&gt;For example.&lt;/p&gt;
315 315 &lt;/blockquote&gt;
316 316
317 317 Output:
318 318
319 319 &lt;p&gt;If you want your page to validate under XHTML 1.0 Strict,
320 320 you've got to put paragraph tags in your blockquotes:&lt;/p&gt;
321
321
322 322 &lt;pre&gt;&lt;code&gt;&amp;lt;blockquote&amp;gt;
323 323 &amp;lt;p&amp;gt;For example.&amp;lt;/p&amp;gt;
324 324 &amp;lt;/blockquote&amp;gt;
325 325 &lt;/code&gt;&lt;/pre&gt;
326 326 </textarea></form>
327 327
328 328 <script>
329 329 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
330 330 mode: 'markdown',
331 331 lineNumbers: true,
332 332 theme: "default",
333 333 extraKeys: {"Enter": "newlineAndIndentContinueMarkdownList"}
334 334 });
335 335 </script>
336 336
337 337 <p>Optionally depends on the XML mode for properly highlighted inline XML blocks.</p>
338 338
339 339 <p><strong>MIME types defined:</strong> <code>text/x-markdown</code>.</p>
340 340
341 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 343 </body>
344 344 </html>
@@ -1,149 +1,149 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: mIRC mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="mirc.js"></script>
9 9 <link rel="stylesheet" href="../../theme/twilight.css">
10 10 <style>.CodeMirror {border: 1px solid black;}</style>
11 11 <link rel="stylesheet" href="../../doc/docs.css">
12 12 </head>
13 13 <body>
14 14 <h1>CodeMirror: mIRC mode</h1>
15 15 <form><textarea id="code" name="code">
16 16 ;AKA Nick Tracker by Ford_Lawnmower irc.GeekShed.net #Script-Help
17 17 ;*****************************************************************************;
18 18 ;**Start Setup
19 19 ;Change JoinDisplay, below, for On Join AKA Display. On = 1 - Off = 0
20 20 alias -l JoinDisplay { return 1 }
21 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 22 alias -l MaxNicks { return 20 }
23 23 ;Change AKALogo, below, To the text you want displayed before each AKA result.
24 24 alias -l AKALogo { return 06 05A06K07A 06 }
25 25 ;**End Setup
26 26 ;*****************************************************************************;
27 27 On *:Join:#: {
28 28 if ($nick == $me) { .timer 1 1 ialupdateCheck $chan }
29 29 NickNamesAdd $nick $+($network,$wildsite)
30 30 if ($JoinDisplay) { .timerNickNames $+ $nick 1 2 NickNames.display $nick $chan $network $wildsite }
31 31 }
32 32 on *:Nick: { NickNamesAdd $newnick $+($network,$wildsite) $nick }
33 33 alias -l NickNames.display {
34 34 if ($gettok($hget(NickNames,$+($3,$4)),0,126) > 1) {
35 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 38 alias -l NickNamesAdd {
39 39 if ($hget(NickNames,$2)) {
40 40 if (!$regex($hget(NickNames,$2),/~\Q $+ $replacecs($1,\E,\E\\E\Q) $+ \E~/i)) {
41 41 if ($gettok($hget(NickNames,$2),0,126) <= $MaxNicks) {
42 42 hadd NickNames $2 $+($hget(NickNames,$2),$1,~)
43 43 }
44 44 else {
45 45 hadd NickNames $2 $+($mid($hget(NickNames,$2),$pos($hget(NickNames,$2),~,2)),$1,~)
46 46 }
47 47 }
48 48 }
49 49 else {
50 50 hadd -m NickNames $2 $+(~,$1,~,$iif($3,$+($3,~)))
51 51 }
52 52 }
53 53 alias -l Fix.All.MindUser {
54 54 var %Fix.Count = $hfind(NickNames,/[^~]+[0-9]{4}~/,0,r).data
55 55 while (%Fix.Count) {
56 56 if ($Fix.MindUser($hget(NickNames,$hfind(NickNames,/[^~]+[0-9]{4}~/,%Fix.Count,r).data))) {
57 57 echo -ag Record %Fix.Count - $v1 - Was Cleaned
58 58 hadd NickNames $hfind(NickNames,/[^~]+[0-9]{4}~/,%Fix.Count,r).data $v1
59 59 }
60 60 dec %Fix.Count
61 61 }
62 62 }
63 63 alias -l Fix.MindUser { return $regsubex($1,/[^~]+[0-9]{4}~/g,$null) }
64 64 menu nicklist,query {
65 65 -
66 66 .AKA
67 67 ..Check $$1: {
68 68 if ($gettok($hget(NickNames,$+($network,$address($1,2))),0,126) > 1) {
69 69 NickNames.display $1 $active $network $address($1,2)
70 70 }
71 71 else { echo -ag $AKALogo $+(09,$1) 07has not been known by any other nicknames while I have been watching. }
72 72 }
73 73 ..Cleanup $$1:hadd NickNames $+($network,$address($1,2)) $fix.minduser($hget(NickNames,$+($network,$address($1,2))))
74 74 ..Clear $$1:hadd NickNames $+($network,$address($1,2)) $+(~,$1,~)
75 75 ..AKA Search Dialog:dialog $iif($dialog(AKA_Search),-v,-m) AKA_Search AKA_Search
76 76 -
77 77 }
78 78 menu status,channel {
79 79 -
80 80 .AKA
81 81 ..AKA Search Dialog:dialog $iif($dialog(AKA_Search),-v,-m) AKA_Search AKA_Search
82 82 ..Clean All Records:Fix.All.Minduser
83 83 -
84 84 }
85 85 dialog AKA_Search {
86 86 title "AKA Search Engine"
87 87 size -1 -1 206 221
88 88 option dbu
89 89 edit "", 1, 8 5 149 10, autohs
90 90 button "Search", 2, 163 4 32 12
91 91 radio "Search HostMask", 4, 61 22 55 10
92 92 radio "Search Nicknames", 5, 123 22 56 10
93 93 list 6, 8 38 190 169, sort extsel vsbar
94 94 button "Check Selected", 7, 67 206 40 12
95 95 button "Close", 8, 160 206 38 12, cancel
96 96 box "Search Type", 3, 11 17 183 18
97 97 button "Copy to Clipboard", 9, 111 206 46 12
98 98 }
99 99 On *:Dialog:Aka_Search:init:*: { did -c $dname 5 }
100 100 On *:Dialog:Aka_Search:Sclick:2,7,9: {
101 101 if ($did == 2) && ($did($dname,1)) {
102 102 did -r $dname 6
103 103 var %search $+(*,$v1,*), %type $iif($did($dname,5).state,data,item), %matches = $hfind(NickNames,%search,0,w). [ $+ [ %type ] ]
104 104 while (%matches) {
105 105 did -a $dname 6 $hfind(NickNames,%search,%matches,w). [ $+ [ %type ] ]
106 106 dec %matches
107 107 }
108 108 did -c $dname 6 1
109 109 }
110 110 elseif ($did == 7) && ($did($dname,6).seltext) { echo -ga $AKALogo 07 $mid($replace($hget(NickNames,$v1),$chr(126),$chr(44)),2,-1) }
111 111 elseif ($did == 9) && ($did($dname,6).seltext) { clipboard $mid($v1,$pos($v1,*,1)) }
112 112 }
113 113 On *:Start:{
114 114 if (!$hget(NickNames)) { hmake NickNames 10 }
115 115 if ($isfile(NickNames.hsh)) { hload NickNames NickNames.hsh }
116 116 }
117 117 On *:Exit: { if ($hget(NickNames)) { hsave NickNames NickNames.hsh } }
118 118 On *:Disconnect: { if ($hget(NickNames)) { hsave NickNames NickNames.hsh } }
119 119 On *:Unload: { hfree NickNames }
120 120 alias -l ialupdateCheck {
121 121 inc -z $+(%,ialupdateCheck,$network) $calc($nick($1,0) / 4)
122 122 ;If your ial is already being updated on join .who $1 out.
123 123 ;If you are using /names to update ial you will still need this line.
124 124 .who $1
125 125 }
126 126 Raw 352:*: {
127 127 if ($($+(%,ialupdateCheck,$network),2)) haltdef
128 128 NickNamesAdd $6 $+($network,$address($6,2))
129 129 }
130 130 Raw 315:*: {
131 131 if ($($+(%,ialupdateCheck,$network),2)) haltdef
132 132 }
133 133
134 134 </textarea></form>
135 135 <script>
136 136 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
137 137 tabMode: "indent",
138 theme: "twilight",
138 theme: "twilight",
139 139 lineNumbers: true,
140 matchBrackets: true,
140 matchBrackets: true,
141 141 indentUnit: 4,
142 142 mode: "text/mirc"
143 143 });
144 144 </script>
145 145
146 146 <p><strong>MIME types defined:</strong> <code>text/mirc</code>.</p>
147 147
148 148 </body>
149 149 </html>
@@ -1,33 +1,33 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: NTriples mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="ntriples.js"></script>
9 9 <link rel="stylesheet" href="../../doc/docs.css">
10 10 <style type="text/css">
11 11 .CodeMirror {
12 12 border: 1px solid #eee;
13 13 }
14 </style>
14 </style>
15 15 </head>
16 16 <body>
17 17 <h1>CodeMirror: NTriples mode</h1>
18 18 <form>
19 <textarea id="ntriples" name="ntriples">
19 <textarea id="ntriples" name="ntriples">
20 20 <http://Sub1> <http://pred1> <http://obj> .
21 21 <http://Sub2> <http://pred2#an2> "literal 1" .
22 22 <http://Sub3#an3> <http://pred3> _:bnode3 .
23 23 _:bnode4 <http://pred4> "literal 2"@lang .
24 24 _:bnode5 <http://pred5> "literal 3"^^<http://type> .
25 25 </textarea>
26 26 </form>
27 27
28 28 <script>
29 29 var editor = CodeMirror.fromTextArea(document.getElementById("ntriples"), {});
30 30 </script>
31 31 <p><strong>MIME types defined:</strong> <code>text/n-triples</code>.</p>
32 32 </body>
33 33 </html>
@@ -1,131 +1,131 b''
1 1 <!doctype html>
2 2 <meta charset=utf-8>
3 3 <title>CodeMirror: OCaml mode</title>
4 4
5 5 <link rel=stylesheet href=../../lib/codemirror.css>
6 6 <link rel=stylesheet href=../../doc/docs.css>
7 7
8 8 <style type=text/css>
9 9 .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
10 10 </style>
11 11
12 12 <script src=../../lib/codemirror.js></script>
13 13 <script src=../../addon/edit/matchbrackets.js></script>
14 14 <script src=ocaml.js></script>
15 15
16 16 <h1>CodeMirror: OCaml mode</h1>
17 17
18 18 <textarea id=code>
19 19 (* Summing a list of integers *)
20 20 let rec sum xs =
21 21 match xs with
22 22 | [] -&gt; 0
23 23 | x :: xs' -&gt; x + sum xs'
24 24
25 25 (* Quicksort *)
26 26 let rec qsort = function
27 27 | [] -&gt; []
28 28 | pivot :: rest -&gt;
29 29 let is_less x = x &lt; pivot in
30 30 let left, right = List.partition is_less rest in
31 31 qsort left @ [pivot] @ qsort right
32 32
33 33 (* Fibonacci Sequence *)
34 34 let rec fib_aux n a b =
35 35 match n with
36 36 | 0 -&gt; a
37 37 | _ -&gt; fib_aux (n - 1) (a + b) a
38 38 let fib n = fib_aux n 0 1
39 39
40 40 (* Birthday paradox *)
41 41 let year_size = 365.
42 42
43 43 let rec birthday_paradox prob people =
44 44 let prob' = (year_size -. float people) /. year_size *. prob in
45 45 if prob' &lt; 0.5 then
46 46 Printf.printf "answer = %d\n" (people+1)
47 47 else
48 48 birthday_paradox prob' (people+1) ;;
49 49
50 50 birthday_paradox 1.0 1
51 51
52 52 (* Church numerals *)
53 53 let zero f x = x
54 54 let succ n f x = f (n f x)
55 55 let one = succ zero
56 56 let two = succ (succ zero)
57 57 let add n1 n2 f x = n1 f (n2 f x)
58 58 let to_string n = n (fun k -&gt; "S" ^ k) "0"
59 59 let _ = to_string (add (succ two) two)
60 60
61 61 (* Elementary functions *)
62 62 let square x = x * x;;
63 63 let rec fact x =
64 64 if x &lt;= 1 then 1 else x * fact (x - 1);;
65 65
66 66 (* Automatic memory management *)
67 67 let l = 1 :: 2 :: 3 :: [];;
68 68 [1; 2; 3];;
69 69 5 :: l;;
70 70
71 71 (* Polymorphism: sorting lists *)
72 72 let rec sort = function
73 73 | [] -&gt; []
74 74 | x :: l -&gt; insert x (sort l)
75 75
76 76 and insert elem = function
77 77 | [] -&gt; [elem]
78 | x :: l -&gt;
78 | x :: l -&gt;
79 79 if elem &lt; x then elem :: x :: l else x :: insert elem l;;
80 80
81 81 (* Imperative features *)
82 82 let add_polynom p1 p2 =
83 83 let n1 = Array.length p1
84 84 and n2 = Array.length p2 in
85 85 let result = Array.create (max n1 n2) 0 in
86 86 for i = 0 to n1 - 1 do result.(i) &lt;- p1.(i) done;
87 87 for i = 0 to n2 - 1 do result.(i) &lt;- result.(i) + p2.(i) done;
88 88 result;;
89 89 add_polynom [| 1; 2 |] [| 1; 2; 3 |];;
90 90
91 91 (* We may redefine fact using a reference cell and a for loop *)
92 92 let fact n =
93 93 let result = ref 1 in
94 94 for i = 2 to n do
95 95 result := i * !result
96 96 done;
97 97 !result;;
98 98 fact 5;;
99 99
100 100 (* Triangle (graphics) *)
101 101 let () =
102 102 ignore( Glut.init Sys.argv );
103 103 Glut.initDisplayMode ~double_buffer:true ();
104 104 ignore (Glut.createWindow ~title:"OpenGL Demo");
105 105 let angle t = 10. *. t *. t in
106 106 let render () =
107 107 GlClear.clear [ `color ];
108 108 GlMat.load_identity ();
109 109 GlMat.rotate ~angle: (angle (Sys.time ())) ~z:1. ();
110 110 GlDraw.begins `triangles;
111 111 List.iter GlDraw.vertex2 [-1., -1.; 0., 1.; 1., -1.];
112 112 GlDraw.ends ();
113 113 Glut.swapBuffers () in
114 114 GlMat.mode `modelview;
115 115 Glut.displayFunc ~cb:render;
116 116 Glut.idleFunc ~cb:(Some Glut.postRedisplay);
117 117 Glut.mainLoop ()
118 118
119 119 (* A Hundred Lines of Caml - http://caml.inria.fr/about/taste.en.html *)
120 120 (* OCaml page on Wikipedia - http://en.wikipedia.org/wiki/OCaml *)
121 121 </textarea>
122 122
123 123 <script>
124 124 var editor = CodeMirror.fromTextArea(document.getElementById('code'), {
125 125 mode: 'ocaml',
126 126 lineNumbers: true,
127 127 matchBrackets: true
128 128 });
129 129 </script>
130 130
131 131 <p><strong>MIME types defined:</strong> <code>text/x-ocaml</code>.</p>
@@ -1,48 +1,48 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: Pascal mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="pascal.js"></script>
9 9 <link rel="stylesheet" href="../../doc/docs.css">
10 10 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
11 11 </head>
12 12 <body>
13 13 <h1>CodeMirror: Pascal mode</h1>
14 14
15 15 <div><textarea id="code" name="code">
16 16 (* Example Pascal code *)
17 17
18 18 while a <> b do writeln('Waiting');
19
20 if a > b then
19
20 if a > b then
21 21 writeln('Condition met')
22 else
22 else
23 23 writeln('Condition not met');
24
25 for i := 1 to 10 do
24
25 for i := 1 to 10 do
26 26 writeln('Iteration: ', i:1);
27
27
28 28 repeat
29 29 a := a + 1
30 30 until a = 10;
31
31
32 32 case i of
33 33 0: write('zero');
34 34 1: write('one');
35 35 2: write('two')
36 36 end;
37 37 </textarea></div>
38 38
39 39 <script>
40 40 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
41 41 lineNumbers: true,
42 42 mode: "text/x-pascal"
43 43 });
44 44 </script>
45 45
46 46 <p><strong>MIME types defined:</strong> <code>text/x-pascal</code>.</p>
47 47 </body>
48 48 </html>
@@ -1,62 +1,62 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: Perl mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="perl.js"></script>
9 9 <link rel="stylesheet" href="../../doc/docs.css">
10 10 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
11 11 </head>
12 12 <body>
13 13 <h1>CodeMirror: Perl mode</h1>
14 14
15 15 <div><textarea id="code" name="code">
16 16 #!/usr/bin/perl
17 17
18 18 use Something qw(func1 func2);
19 19
20 20 # strings
21 21 my $s1 = qq'single line';
22 22 our $s2 = q(multi-
23 23 line);
24 24
25 25 =item Something
26 Example.
26 Example.
27 27 =cut
28 28
29 29 my $html=<<'HTML'
30 30 <html>
31 31 <title>hi!</title>
32 32 </html>
33 33 HTML
34 34
35 35 print "first,".join(',', 'second', qq~third~);
36 36
37 37 if($s1 =~ m[(?<!\s)(l.ne)\z]o) {
38 $h->{$1}=$$.' predefined variables';
39 $s2 =~ s/\-line//ox;
40 $s1 =~ s[
41 line ]
42 [
43 block
44 ]ox;
38 $h->{$1}=$$.' predefined variables';
39 $s2 =~ s/\-line//ox;
40 $s1 =~ s[
41 line ]
42 [
43 block
44 ]ox;
45 45 }
46 46
47 47 1; # numbers and comments
48 48
49 49 __END__
50 50 something...
51 51
52 52 </textarea></div>
53 53
54 54 <script>
55 55 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
56 56 lineNumbers: true
57 57 });
58 58 </script>
59 59
60 60 <p><strong>MIME types defined:</strong> <code>text/x-perl</code>.</p>
61 61 </body>
62 62 </html>
@@ -1,51 +1,51 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: PHP mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="../../addon/edit/matchbrackets.js"></script>
9 9 <script src="../htmlmixed/htmlmixed.js"></script>
10 10 <script src="../xml/xml.js"></script>
11 11 <script src="../javascript/javascript.js"></script>
12 12 <script src="../css/css.js"></script>
13 13 <script src="../clike/clike.js"></script>
14 14 <script src="php.js"></script>
15 15 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
16 16 <link rel="stylesheet" href="../../doc/docs.css">
17 17 </head>
18 18 <body>
19 19 <h1>CodeMirror: PHP mode</h1>
20 20
21 21 <form><textarea id="code" name="code">
22 22 <?php
23 23 function hello($who) {
24 return "Hello " . $who;
24 return "Hello " . $who;
25 25 }
26 26 ?>
27 27 <p>The program says <?= hello("World") ?>.</p>
28 28 <script>
29 alert("And here is some JS code"); // also colored
29 alert("And here is some JS code"); // also colored
30 30 </script>
31 31 </textarea></form>
32 32
33 33 <script>
34 34 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
35 35 lineNumbers: true,
36 36 matchBrackets: true,
37 37 mode: "application/x-httpd-php",
38 38 indentUnit: 4,
39 39 indentWithTabs: true,
40 40 enterMode: "keep",
41 41 tabMode: "shift"
42 42 });
43 43 </script>
44 44
45 45 <p>Simple HTML/PHP mode based on
46 46 the <a href="../clike">C-like</a> mode. Depends on XML,
47 47 JavaScript, CSS, HTMLMixed, and C-like modes.</p>
48 48
49 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 50 </body>
51 51 </html>
@@ -1,42 +1,42 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: Pig Latin mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="pig.js"></script>
9 9 <link rel="stylesheet" href="../../doc/docs.css">
10 10 <style>.CodeMirror {border: 2px inset #dee;}</style>
11 11 </head>
12 12 <body>
13 13 <h1>CodeMirror: Pig Latin mode</h1>
14 14
15 15 <form><textarea id="code" name="code">
16 16 -- Apache Pig (Pig Latin Language) Demo
17 /*
17 /*
18 18 This is a multiline comment.
19 19 */
20 20 a = LOAD "\path\to\input" USING PigStorage('\t') AS (x:long, y:chararray, z:bytearray);
21 21 b = GROUP a BY (x,y,3+4);
22 22 c = FOREACH b GENERATE flatten(group) as (x,y), SUM(group.$2) as z;
23 23 STORE c INTO "\path\to\output";
24 24
25 25 --
26 26 </textarea></form>
27 27
28 28 <script>
29 29 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
30 30 lineNumbers: true,
31 31 indentUnit: 4,
32 32 mode: "text/x-pig"
33 33 });
34 34 </script>
35 35
36 36 <p>
37 37 Simple mode that handles Pig Latin language.
38 38 </p>
39 39
40 40 <p><strong>MIME type defined:</strong> <code>text/x-pig</code>
41 41 (PIG code)
42 42 </html>
@@ -1,21 +1,21 b''
1 1 The MIT License
2 2
3 3 Copyright (c) 2010 Timothy Farrell
4 4
5 5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 6 of this software and associated documentation files (the "Software"), to deal
7 7 in the Software without restriction, including without limitation the rights
8 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 9 copies of the Software, and to permit persons to whom the Software is
10 10 furnished to do so, subject to the following conditions:
11 11
12 12 The above copyright notice and this permission notice shall be included in
13 13 all copies or substantial portions of the Software.
14 14
15 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 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 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: Python mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="../../addon/edit/matchbrackets.js"></script>
9 9 <script src="python.js"></script>
10 10 <link rel="stylesheet" href="../../doc/docs.css">
11 11 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
12 12 </head>
13 13 <body>
14 14 <h1>CodeMirror: Python mode</h1>
15
15
16 16 <div><textarea id="code" name="code">
17 17 # Literals
18 18 1234
19 19 0.0e101
20 20 .123
21 21 0b01010011100
22 22 0o01234567
23 23 0x0987654321abcdef
24 24 7
25 25 2147483647
26 26 3L
27 27 79228162514264337593543950336L
28 28 0x100000000L
29 29 79228162514264337593543950336
30 30 0xdeadbeef
31 31 3.14j
32 32 10.j
33 33 10j
34 34 .001j
35 35 1e100j
36 36 3.14e-10j
37 37
38 38
39 39 # String Literals
40 40 'For\''
41 41 "God\""
42 42 """so loved
43 43 the world"""
44 44 '''that he gave
45 45 his only begotten\' '''
46 46 'that whosoever believeth \
47 47 in him'
48 48 ''
49 49
50 50 # Identifiers
51 51 __a__
52 52 a.b
53 53 a.b.c
54 54
55 55 # Operators
56 56 + - * / % & | ^ ~ < >
57 57 == != <= >= <> << >> // **
58 58 and or not in is
59 59
60 60 # Delimiters
61 61 () [] {} , : ` = ; @ . # Note that @ and . require the proper context.
62 62 += -= *= /= %= &= |= ^=
63 63 //= >>= <<= **=
64 64
65 65 # Keywords
66 66 as assert break class continue def del elif else except
67 67 finally for from global if import lambda pass raise
68 68 return try while with yield
69 69
70 70 # Python 2 Keywords (otherwise Identifiers)
71 71 exec print
72 72
73 73 # Python 3 Keywords (otherwise Identifiers)
74 74 nonlocal
75 75
76 76 # Types
77 77 bool classmethod complex dict enumerate float frozenset int list object
78 78 property reversed set slice staticmethod str super tuple type
79 79
80 80 # Python 2 Types (otherwise Identifiers)
81 81 basestring buffer file long unicode xrange
82 82
83 83 # Python 3 Types (otherwise Identifiers)
84 84 bytearray bytes filter map memoryview open range zip
85 85
86 86 # Some Example code
87 87 import os
88 88 from package import ParentClass
89 89
90 90 @nonsenseDecorator
91 91 def doesNothing():
92 92 pass
93 93
94 94 class ExampleClass(ParentClass):
95 95 @staticmethod
96 96 def example(inputStr):
97 97 a = list(inputStr)
98 98 a.reverse()
99 99 return ''.join(a)
100 100
101 101 def __init__(self, mixin = 'Hello'):
102 102 self.mixin = mixin
103 103
104 104 </textarea></div>
105 105 <script>
106 106 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
107 107 mode: {name: "python",
108 108 version: 2,
109 109 singleLineStringErrors: false},
110 110 lineNumbers: true,
111 111 indentUnit: 4,
112 112 tabMode: "shift",
113 113 matchBrackets: true
114 114 });
115 115 </script>
116 116 <h2>Configuration Options:</h2>
117 117 <ul>
118 118 <li>version - 2/3 - The version of Python to recognize. Default is 2.</li>
119 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 120 </ul>
121 121 <h2>Advanced Configuration Options:</h2>
122 122 <p>Usefull for superset of python syntax like Enthought enaml, IPython magics and questionmark help</p>
123 123 <ul>
124 124 <li>singleOperators - RegEx - Regular Expression for single operator matching, default : <pre>^[\\+\\-\\*/%&amp;|\\^~&lt;&gt;!]</pre></li>
125 125 <li>singleDelimiters - RegEx - Regular Expression for single delimiter matching, default : <pre>^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]</pre></li>
126 126 <li>doubleOperators - RegEx - Regular Expression for double operators matching, default : <pre>^((==)|(!=)|(&lt;=)|(&gt;=)|(&lt;&gt;)|(&lt;&lt;)|(&gt;&gt;)|(//)|(\\*\\*))</pre></li>
127 127 <li>doubleDelimiters - RegEx - Regular Expressoin for double delimiters matching, default : <pre>^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&amp;=)|(\\|=)|(\\^=))</pre></li>
128 128 <li>tripleDelimiters - RegEx - Regular Expression for triple delimiters matching, default : <pre>^((//=)|(&gt;&gt;=)|(&lt;&lt;=)|(\\*\\*=))</pre></li>
129 129 <li>identifiers - RegEx - Regular Expression for identifier, default : <pre>^[_A-Za-z][_A-Za-z0-9]*</pre></li>
130 130 </ul>
131 131
132 132
133 133 <p><strong>MIME types defined:</strong> <code>text/x-python</code>.</p>
134 134 </body>
135 135 </html>
@@ -1,131 +1,131 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: Q mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="../../addon/edit/matchbrackets.js"></script>
9 9 <script src="q.js"></script>
10 10 <link rel="stylesheet" href="../../doc/docs.css">
11 11 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
12 12 </head>
13 13 <body>
14 14 <h1>CodeMirror: Q mode</h1>
15 15
16 16 <div><textarea id="code" name="code">
17 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 20 / .csv.colhdrs[file] - return a list of colhdrs from file
21 21 / info:.csv.info[file] - return a table of information about the file
22 / columns are:
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
25 / maybe - needs checking, _could_ be say a date, but perhaps just a float?
22 / columns are:
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
25 / maybe - needs checking, _could_ be say a date, but perhaps just a float?
26 26 / .csv.info0[file;onlycols] - like .csv.info except that it only analyses <onlycols>
27 27 / example:
28 / info:.csv.info0[file;(.csv.colhdrs file)like"*price"]
29 / info:.csv.infolike[file;"*price"]
30 / show delete from info where t=" "
28 / info:.csv.info0[file;(.csv.colhdrs file)like"*price"]
29 / info:.csv.infolike[file;"*price"]
30 / show delete from info where t=" "
31 31 / .csv.data[file;info] - use the info from .csv.info to read the data
32 32 / .csv.data10[file;info] - like .csv.data but only returns the first 10 rows
33 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 36 \d .csv
37 37 DELIM:","
38 38 ZAPHDRS:0b / lowercase and remove _ from colhdrs (junk characters are always removed)
39 39 WIDTHHDR:25000 / number of characters read to get the header
40 40 READLINES:222 / number of lines read and used to guess the types
41 41 SYMMAXWIDTH:11 / character columns narrower than this are stored as symbols
42 42 SYMMAXGR:10 / max symbol granularity% before we give up and keep as a * string
43 43 FORCECHARWIDTH:30 / every field (of any type) with values this wide or more is forced to character "*"
44 44 DISCARDEMPTY:0b / completely ignore empty columns if true else set them to "C"
45 45 CHUNKSIZE:50000000 / used in fs2 (modified .Q.fs)
46 46
47 47 k)nameltrim:{$[~@x;.z.s'x;~(*x)in aA:.Q.a,.Q.A;(+/&\~x in aA)_x;x]}
48 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 49 cleanhdrs:{{$[ZAPHDRS;lower x except"_";x]}x where x in DELIM,.Q.an}
50 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]]}
53 read10:{[file]data10[file;info[file]]}
52 read:{[file]data[file;info[file]]}
53 read10:{[file]data10[file;info[file]]}
54 54
55 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 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 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 61 info0:{[file;onlycols]
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"];
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);
66 info:([]c:key flip as;v:value flip as);as:();
67 reserved:key`.q;reserved,:.Q.res;reserved,:`i;
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;
70 info:update ci:`s#ci from info;
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;
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;
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
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;
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
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;
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;
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;
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
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;
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;
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;
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;
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
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
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)
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
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;
107 select c,ci,t,maybe,empty,res,j10,j12,ipa,mw,mdot,rule,gr,ndv,dchar from info}
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"];
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);
66 info:([]c:key flip as;v:value flip as);as:();
67 reserved:key`.q;reserved,:.Q.res;reserved,:`i;
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;
70 info:update ci:`s#ci from info;
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;
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;
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
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;
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
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;
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;
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;
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
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;
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;
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;
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;
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
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
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)
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
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;
107 select c,ci,t,maybe,empty,res,j10,j12,ipa,mw,mdot,rule,gr,ndv,dchar from info}
108 108 info:info0[;()] / by default don't restrict columns
109 109 infolike:{[file;pattern] info0[file;{x where x like y}[lower colhdrs[file];pattern]]} / .csv.infolike[file;"*time"]
110 110
111 111 \d .
112 112 / DATA:()
113 113 bulkload:{[file;info]
114 if[not`DATA in system"v";'`DATA.not.defined];
115 if[count DATA;'`DATA.not.empty];
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]];
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
114 if[not`DATA in system"v";'`DATA.not.defined];
115 if[count DATA;'`DATA.not.empty];
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]];
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
120 120 </textarea></div>
121 121
122 122 <script>
123 123 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
124 124 lineNumbers: true,
125 125 matchBrackets: true
126 126 });
127 127 </script>
128 128
129 129 <p><strong>MIME type defined:</strong> <code>text/x-q</code>.</p>
130 130 </body>
131 131 </html>
@@ -1,53 +1,53 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: RPM changes mode</title>
6 6 <link rel="stylesheet" href="../../../lib/codemirror.css">
7 7 <script src="../../../lib/codemirror.js"></script>
8 8 <script src="changes.js"></script>
9 9 <link rel="stylesheet" href="../../../doc/docs.css">
10 10 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
11 11 </head>
12 12 <body>
13 13 <h1>CodeMirror: RPM changes mode</h1>
14
14
15 15 <div><textarea id="code" name="code">
16 16 -------------------------------------------------------------------
17 17 Tue Oct 18 13:58:40 UTC 2011 - misterx@example.com
18 18
19 19 - Update to r60.3
20 20 - Fixes bug in the reflect package
21 21 * disallow Interface method on Value obtained via unexported name
22 22
23 23 -------------------------------------------------------------------
24 24 Thu Oct 6 08:14:24 UTC 2011 - misterx@example.com
25 25
26 26 - Update to r60.2
27 27 - Fixes memory leak in certain map types
28 28
29 29 -------------------------------------------------------------------
30 30 Wed Oct 5 14:34:10 UTC 2011 - misterx@example.com
31 31
32 32 - Tweaks for gdb debugging
33 33 - go.spec changes:
34 34 - move %go_arch definition to %prep section
35 35 - pass correct location of go specific gdb pretty printer and
36 36 functions to cpp as HOST_EXTRA_CFLAGS macro
37 37 - install go gdb functions & printer
38 38 - gdb-printer.patch
39 39 - patch linker (src/cmd/ld/dwarf.c) to emit correct location of go
40 40 gdb functions and pretty printer
41 41 </textarea></div>
42 42 <script>
43 43 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
44 44 mode: {name: "changes"},
45 45 lineNumbers: true,
46 46 indentUnit: 4,
47 47 tabMode: "shift"
48 48 });
49 49 </script>
50 50
51 51 <p><strong>MIME types defined:</strong> <code>text/x-rpm-changes</code>.</p>
52 52 </body>
53 53 </html>
@@ -1,99 +1,99 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: RPM spec mode</title>
6 6 <link rel="stylesheet" href="../../../lib/codemirror.css">
7 7 <script src="../../../lib/codemirror.js"></script>
8 8 <script src="spec.js"></script>
9 9 <link rel="stylesheet" href="spec.css">
10 10 <link rel="stylesheet" href="../../../doc/docs.css">
11 11 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
12 12 </head>
13 13 <body>
14 14 <h1>CodeMirror: RPM spec mode</h1>
15
15
16 16 <div><textarea id="code" name="code">
17 17 #
18 18 # spec file for package minidlna
19 19 #
20 20 # Copyright (c) 2011, Sascha Peilicke <saschpe@gmx.de>
21 21 #
22 22 # All modifications and additions to the file contributed by third parties
23 23 # remain the property of their copyright owners, unless otherwise agreed
24 24 # upon. The license for this file, and modifications and additions to the
25 25 # file, is the same license as for the pristine package itself (unless the
26 26 # license for the pristine package is not an Open Source License, in which
27 27 # case the license is the MIT License). An "Open Source License" is a
28 28 # license that conforms to the Open Source Definition (Version 1.9)
29 29 # published by the Open Source Initiative.
30 30
31 31
32 32 Name: libupnp6
33 33 Version: 1.6.13
34 34 Release: 0
35 35 Summary: Portable Universal Plug and Play (UPnP) SDK
36 36 Group: System/Libraries
37 37 License: BSD-3-Clause
38 38 Url: http://sourceforge.net/projects/pupnp/
39 39 Source0: http://downloads.sourceforge.net/pupnp/libupnp-%{version}.tar.bz2
40 40 BuildRoot: %{_tmppath}/%{name}-%{version}-build
41 41
42 42 %description
43 43 The portable Universal Plug and Play (UPnP) SDK provides support for building
44 44 UPnP-compliant control points, devices, and bridges on several operating
45 45 systems.
46 46
47 47 %package -n libupnp-devel
48 48 Summary: Portable Universal Plug and Play (UPnP) SDK
49 49 Group: Development/Libraries/C and C++
50 50 Provides: pkgconfig(libupnp)
51 51 Requires: %{name} = %{version}
52 52
53 53 %description -n libupnp-devel
54 54 The portable Universal Plug and Play (UPnP) SDK provides support for building
55 55 UPnP-compliant control points, devices, and bridges on several operating
56 56 systems.
57 57
58 58 %prep
59 59 %setup -n libupnp-%{version}
60 60
61 61 %build
62 62 %configure --disable-static
63 63 make %{?_smp_mflags}
64 64
65 65 %install
66 66 %makeinstall
67 67 find %{buildroot} -type f -name '*.la' -exec rm -f {} ';'
68 68
69 69 %post -p /sbin/ldconfig
70 70
71 71 %postun -p /sbin/ldconfig
72 72
73 73 %files
74 74 %defattr(-,root,root,-)
75 75 %doc ChangeLog NEWS README TODO
76 76 %{_libdir}/libixml.so.*
77 77 %{_libdir}/libthreadutil.so.*
78 78 %{_libdir}/libupnp.so.*
79 79
80 80 %files -n libupnp-devel
81 81 %defattr(-,root,root,-)
82 82 %{_libdir}/pkgconfig/libupnp.pc
83 83 %{_libdir}/libixml.so
84 84 %{_libdir}/libthreadutil.so
85 85 %{_libdir}/libupnp.so
86 86 %{_includedir}/upnp/
87 87
88 88 %changelog</textarea></div>
89 89 <script>
90 90 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
91 91 mode: {name: "spec"},
92 92 lineNumbers: true,
93 93 indentUnit: 4
94 94 });
95 95 </script>
96 96
97 97 <p><strong>MIME types defined:</strong> <code>text/x-rpm-spec</code>.</p>
98 98 </body>
99 99 </html>
@@ -1,21 +1,21 b''
1 1 The MIT License
2 2
3 3 Copyright (c) 2013 Hasan Karahan
4 4
5 5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 6 of this software and associated documentation files (the "Software"), to deal
7 7 in the Software without restriction, including without limitation the rights
8 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 9 copies of the Software, and to permit persons to whom the Software is
10 10 furnished to do so, subject to the following conditions:
11 11
12 12 The above copyright notice and this permission notice shall be included in
13 13 all copies or substantial portions of the Software.
14 14
15 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 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 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: reStructuredText mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="rst.js"></script>
9 9 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
10 10 <link rel="stylesheet" href="../../doc/docs.css">
11 11 </head>
12 12 <body>
13 13 <h1>CodeMirror: reStructuredText mode</h1>
14 14
15 15 <form><textarea id="code" name="code">
16 16 .. This is an excerpt from Sphinx documentation: http://sphinx.pocoo.org/_sources/rest.txt
17 17
18 18 .. highlightlang:: rest
19 19
20 20 .. _rst-primer:
21 21
22 22 reStructuredText Primer
23 23 =======================
24 24
25 25 This section is a brief introduction to reStructuredText (reST) concepts and
26 26 syntax, intended to provide authors with enough information to author documents
27 27 productively. Since reST was designed to be a simple, unobtrusive markup
28 28 language, this will not take too long.
29 29
30 30 .. seealso::
31 31
32 32 The authoritative `reStructuredText User Documentation
33 33 &lt;http://docutils.sourceforge.net/rst.html&gt;`_. The "ref" links in this
34 34 document link to the description of the individual constructs in the reST
35 35 reference.
36 36
37 37
38 38 Paragraphs
39 39 ----------
40 40
41 41 The paragraph (:duref:`ref &lt;paragraphs&gt;`) is the most basic block in a reST
42 42 document. Paragraphs are simply chunks of text separated by one or more blank
43 43 lines. As in Python, indentation is significant in reST, so all lines of the
44 44 same paragraph must be left-aligned to the same level of indentation.
45 45
46 46
47 47 .. _inlinemarkup:
48 48
49 49 Inline markup
50 50 -------------
51 51
52 52 The standard reST inline markup is quite simple: use
53 53
54 54 * one asterisk: ``*text*`` for emphasis (italics),
55 55 * two asterisks: ``**text**`` for strong emphasis (boldface), and
56 56 * backquotes: ````text```` for code samples.
57 57
58 58 If asterisks or backquotes appear in running text and could be confused with
59 59 inline markup delimiters, they have to be escaped with a backslash.
60 60
61 61 Be aware of some restrictions of this markup:
62 62
63 63 * it may not be nested,
64 64 * content may not start or end with whitespace: ``* text*`` is wrong,
65 65 * it must be separated from surrounding text by non-word characters. Use a
66 66 backslash escaped space to work around that: ``thisis\ *one*\ word``.
67 67
68 68 These restrictions may be lifted in future versions of the docutils.
69 69
70 70 reST also allows for custom "interpreted text roles"', which signify that the
71 71 enclosed text should be interpreted in a specific way. Sphinx uses this to
72 72 provide semantic markup and cross-referencing of identifiers, as described in
73 73 the appropriate section. The general syntax is ``:rolename:`content```.
74 74
75 75 Standard reST provides the following roles:
76 76
77 77 * :durole:`emphasis` -- alternate spelling for ``*emphasis*``
78 78 * :durole:`strong` -- alternate spelling for ``**strong**``
79 79 * :durole:`literal` -- alternate spelling for ````literal````
80 80 * :durole:`subscript` -- subscript text
81 81 * :durole:`superscript` -- superscript text
82 82 * :durole:`title-reference` -- for titles of books, periodicals, and other
83 83 materials
84 84
85 85 See :ref:`inline-markup` for roles added by Sphinx.
86 86
87 87
88 88 Lists and Quote-like blocks
89 89 ---------------------------
90 90
91 91 List markup (:duref:`ref &lt;bullet-lists&gt;`) is natural: just place an asterisk at
92 92 the start of a paragraph and indent properly. The same goes for numbered lists;
93 93 they can also be autonumbered using a ``#`` sign::
94 94
95 95 * This is a bulleted list.
96 96 * It has two items, the second
97 97 item uses two lines.
98 98
99 99 1. This is a numbered list.
100 100 2. It has two items too.
101 101
102 102 #. This is a numbered list.
103 103 #. It has two items too.
104 104
105 105
106 106 Nested lists are possible, but be aware that they must be separated from the
107 107 parent list items by blank lines::
108 108
109 109 * this is
110 110 * a list
111 111
112 112 * with a nested list
113 113 * and some subitems
114 114
115 115 * and here the parent list continues
116 116
117 117 Definition lists (:duref:`ref &lt;definition-lists&gt;`) are created as follows::
118 118
119 119 term (up to a line of text)
120 120 Definition of the term, which must be indented
121 121
122 122 and can even consist of multiple paragraphs
123 123
124 124 next term
125 125 Description.
126 126
127 127 Note that the term cannot have more than one line of text.
128 128
129 129 Quoted paragraphs (:duref:`ref &lt;block-quotes&gt;`) are created by just indenting
130 130 them more than the surrounding paragraphs.
131 131
132 132 Line blocks (:duref:`ref &lt;line-blocks&gt;`) are a way of preserving line breaks::
133 133
134 134 | These lines are
135 135 | broken exactly like in
136 136 | the source file.
137 137
138 138 There are also several more special blocks available:
139 139
140 140 * field lists (:duref:`ref &lt;field-lists&gt;`)
141 141 * option lists (:duref:`ref &lt;option-lists&gt;`)
142 142 * quoted literal blocks (:duref:`ref &lt;quoted-literal-blocks&gt;`)
143 143 * doctest blocks (:duref:`ref &lt;doctest-blocks&gt;`)
144 144
145 145
146 146 Source Code
147 147 -----------
148 148
149 149 Literal code blocks (:duref:`ref &lt;literal-blocks&gt;`) are introduced by ending a
150 150 paragraph with the special marker ``::``. The literal block must be indented
151 151 (and, like all paragraphs, separated from the surrounding ones by blank lines)::
152 152
153 153 This is a normal text paragraph. The next paragraph is a code sample::
154 154
155 155 It is not processed in any way, except
156 156 that the indentation is removed.
157 157
158 158 It can span multiple lines.
159 159
160 160 This is a normal text paragraph again.
161 161
162 162 The handling of the ``::`` marker is smart:
163 163
164 164 * If it occurs as a paragraph of its own, that paragraph is completely left
165 165 out of the document.
166 166 * If it is preceded by whitespace, the marker is removed.
167 167 * If it is preceded by non-whitespace, the marker is replaced by a single
168 168 colon.
169 169
170 170 That way, the second sentence in the above example's first paragraph would be
171 171 rendered as "The next paragraph is a code sample:".
172 172
173 173
174 174 .. _rst-tables:
175 175
176 176 Tables
177 177 ------
178 178
179 179 Two forms of tables are supported. For *grid tables* (:duref:`ref
180 180 &lt;grid-tables&gt;`), you have to "paint" the cell grid yourself. They look like
181 181 this::
182 182
183 183 +------------------------+------------+----------+----------+
184 184 | Header row, column 1 | Header 2 | Header 3 | Header 4 |
185 185 | (header rows optional) | | | |
186 186 +========================+============+==========+==========+
187 187 | body row 1, column 1 | column 2 | column 3 | column 4 |
188 188 +------------------------+------------+----------+----------+
189 189 | body row 2 | ... | ... | |
190 190 +------------------------+------------+----------+----------+
191 191
192 192 *Simple tables* (:duref:`ref &lt;simple-tables&gt;`) are easier to write, but
193 193 limited: they must contain more than one row, and the first column cannot
194 194 contain multiple lines. They look like this::
195 195
196 196 ===== ===== =======
197 197 A B A and B
198 198 ===== ===== =======
199 199 False False False
200 200 True False False
201 201 False True False
202 202 True True True
203 203 ===== ===== =======
204 204
205 205
206 206 Hyperlinks
207 207 ----------
208 208
209 209 External links
210 210 ^^^^^^^^^^^^^^
211 211
212 212 Use ```Link text &lt;http://example.com/&gt;`_`` for inline web links. If the link
213 213 text should be the web address, you don't need special markup at all, the parser
214 214 finds links and mail addresses in ordinary text.
215 215
216 216 You can also separate the link and the target definition (:duref:`ref
217 217 &lt;hyperlink-targets&gt;`), like this::
218 218
219 219 This is a paragraph that contains `a link`_.
220 220
221 221 .. _a link: http://example.com/
222 222
223 223
224 224 Internal links
225 225 ^^^^^^^^^^^^^^
226 226
227 227 Internal linking is done via a special reST role provided by Sphinx, see the
228 228 section on specific markup, :ref:`ref-role`.
229 229
230 230
231 231 Sections
232 232 --------
233 233
234 234 Section headers (:duref:`ref &lt;sections&gt;`) are created by underlining (and
235 235 optionally overlining) the section title with a punctuation character, at least
236 236 as long as the text::
237 237
238 238 =================
239 239 This is a heading
240 240 =================
241 241
242 242 Normally, there are no heading levels assigned to certain characters as the
243 243 structure is determined from the succession of headings. However, for the
244 244 Python documentation, this convention is used which you may follow:
245 245
246 246 * ``#`` with overline, for parts
247 247 * ``*`` with overline, for chapters
248 248 * ``=``, for sections
249 249 * ``-``, for subsections
250 250 * ``^``, for subsubsections
251 251 * ``"``, for paragraphs
252 252
253 253 Of course, you are free to use your own marker characters (see the reST
254 254 documentation), and use a deeper nesting level, but keep in mind that most
255 255 target formats (HTML, LaTeX) have a limited supported nesting depth.
256 256
257 257
258 258 Explicit Markup
259 259 ---------------
260 260
261 261 "Explicit markup" (:duref:`ref &lt;explicit-markup-blocks&gt;`) is used in reST for
262 262 most constructs that need special handling, such as footnotes,
263 263 specially-highlighted paragraphs, comments, and generic directives.
264 264
265 265 An explicit markup block begins with a line starting with ``..`` followed by
266 266 whitespace and is terminated by the next paragraph at the same level of
267 267 indentation. (There needs to be a blank line between explicit markup and normal
268 268 paragraphs. This may all sound a bit complicated, but it is intuitive enough
269 269 when you write it.)
270 270
271 271
272 272 .. _directives:
273 273
274 274 Directives
275 275 ----------
276 276
277 277 A directive (:duref:`ref &lt;directives&gt;`) is a generic block of explicit markup.
278 278 Besides roles, it is one of the extension mechanisms of reST, and Sphinx makes
279 279 heavy use of it.
280 280
281 281 Docutils supports the following directives:
282 282
283 283 * Admonitions: :dudir:`attention`, :dudir:`caution`, :dudir:`danger`,
284 284 :dudir:`error`, :dudir:`hint`, :dudir:`important`, :dudir:`note`,
285 285 :dudir:`tip`, :dudir:`warning` and the generic :dudir:`admonition`.
286 286 (Most themes style only "note" and "warning" specially.)
287 287
288 288 * Images:
289 289
290 290 - :dudir:`image` (see also Images_ below)
291 291 - :dudir:`figure` (an image with caption and optional legend)
292 292
293 293 * Additional body elements:
294 294
295 295 - :dudir:`contents` (a local, i.e. for the current file only, table of
296 296 contents)
297 297 - :dudir:`container` (a container with a custom class, useful to generate an
298 298 outer ``&lt;div&gt;`` in HTML)
299 299 - :dudir:`rubric` (a heading without relation to the document sectioning)
300 300 - :dudir:`topic`, :dudir:`sidebar` (special highlighted body elements)
301 301 - :dudir:`parsed-literal` (literal block that supports inline markup)
302 302 - :dudir:`epigraph` (a block quote with optional attribution line)
303 303 - :dudir:`highlights`, :dudir:`pull-quote` (block quotes with their own
304 304 class attribute)
305 305 - :dudir:`compound` (a compound paragraph)
306 306
307 307 * Special tables:
308 308
309 309 - :dudir:`table` (a table with title)
310 310 - :dudir:`csv-table` (a table generated from comma-separated values)
311 311 - :dudir:`list-table` (a table generated from a list of lists)
312 312
313 313 * Special directives:
314 314
315 315 - :dudir:`raw` (include raw target-format markup)
316 316 - :dudir:`include` (include reStructuredText from another file)
317 317 -- in Sphinx, when given an absolute include file path, this directive takes
318 318 it as relative to the source directory
319 319 - :dudir:`class` (assign a class attribute to the next element) [1]_
320 320
321 321 * HTML specifics:
322 322
323 323 - :dudir:`meta` (generation of HTML ``&lt;meta&gt;`` tags)
324 324 - :dudir:`title` (override document title)
325 325
326 326 * Influencing markup:
327 327
328 328 - :dudir:`default-role` (set a new default role)
329 329 - :dudir:`role` (create a new role)
330 330
331 331 Since these are only per-file, better use Sphinx' facilities for setting the
332 332 :confval:`default_role`.
333 333
334 334 Do *not* use the directives :dudir:`sectnum`, :dudir:`header` and
335 335 :dudir:`footer`.
336 336
337 337 Directives added by Sphinx are described in :ref:`sphinxmarkup`.
338 338
339 339 Basically, a directive consists of a name, arguments, options and content. (Keep
340 340 this terminology in mind, it is used in the next chapter describing custom
341 341 directives.) Looking at this example, ::
342 342
343 343 .. function:: foo(x)
344 344 foo(y, z)
345 345 :module: some.module.name
346 346
347 347 Return a line of text input from the user.
348 348
349 349 ``function`` is the directive name. It is given two arguments here, the
350 350 remainder of the first line and the second line, as well as one option
351 351 ``module`` (as you can see, options are given in the lines immediately following
352 352 the arguments and indicated by the colons). Options must be indented to the
353 353 same level as the directive content.
354 354
355 355 The directive content follows after a blank line and is indented relative to the
356 356 directive start.
357 357
358 358
359 359 Images
360 360 ------
361 361
362 362 reST supports an image directive (:dudir:`ref &lt;image&gt;`), used like so::
363 363
364 364 .. image:: gnu.png
365 365 (options)
366 366
367 367 When used within Sphinx, the file name given (here ``gnu.png``) must either be
368 368 relative to the source file, or absolute which means that they are relative to
369 369 the top source directory. For example, the file ``sketch/spam.rst`` could refer
370 370 to the image ``images/spam.png`` as ``../images/spam.png`` or
371 371 ``/images/spam.png``.
372 372
373 373 Sphinx will automatically copy image files over to a subdirectory of the output
374 374 directory on building (e.g. the ``_static`` directory for HTML output.)
375 375
376 376 Interpretation of image size options (``width`` and ``height``) is as follows:
377 377 if the size has no unit or the unit is pixels, the given size will only be
378 378 respected for output channels that support pixels (i.e. not in LaTeX output).
379 379 Other units (like ``pt`` for points) will be used for HTML and LaTeX output.
380 380
381 381 Sphinx extends the standard docutils behavior by allowing an asterisk for the
382 382 extension::
383 383
384 384 .. image:: gnu.*
385 385
386 386 Sphinx then searches for all images matching the provided pattern and determines
387 387 their type. Each builder then chooses the best image out of these candidates.
388 388 For instance, if the file name ``gnu.*`` was given and two files :file:`gnu.pdf`
389 389 and :file:`gnu.png` existed in the source tree, the LaTeX builder would choose
390 390 the former, while the HTML builder would prefer the latter.
391 391
392 392 .. versionchanged:: 0.4
393 393 Added the support for file names ending in an asterisk.
394 394
395 395 .. versionchanged:: 0.6
396 396 Image paths can now be absolute.
397 397
398 398
399 399 Footnotes
400 400 ---------
401 401
402 402 For footnotes (:duref:`ref &lt;footnotes&gt;`), use ``[#name]_`` to mark the footnote
403 403 location, and add the footnote body at the bottom of the document after a
404 404 "Footnotes" rubric heading, like so::
405 405
406 406 Lorem ipsum [#f1]_ dolor sit amet ... [#f2]_
407 407
408 408 .. rubric:: Footnotes
409 409
410 410 .. [#f1] Text of the first footnote.
411 411 .. [#f2] Text of the second footnote.
412 412
413 413 You can also explicitly number the footnotes (``[1]_``) or use auto-numbered
414 414 footnotes without names (``[#]_``).
415 415
416 416
417 417 Citations
418 418 ---------
419 419
420 420 Standard reST citations (:duref:`ref &lt;citations&gt;`) are supported, with the
421 421 additional feature that they are "global", i.e. all citations can be referenced
422 422 from all files. Use them like so::
423 423
424 424 Lorem ipsum [Ref]_ dolor sit amet.
425 425
426 426 .. [Ref] Book or article reference, URL or whatever.
427 427
428 428 Citation usage is similar to footnote usage, but with a label that is not
429 429 numeric or begins with ``#``.
430 430
431 431
432 432 Substitutions
433 433 -------------
434 434
435 435 reST supports "substitutions" (:duref:`ref &lt;substitution-definitions&gt;`), which
436 436 are pieces of text and/or markup referred to in the text by ``|name|``. They
437 437 are defined like footnotes with explicit markup blocks, like this::
438 438
439 439 .. |name| replace:: replacement *text*
440 440
441 441 or this::
442 442
443 443 .. |caution| image:: warning.png
444 444 :alt: Warning!
445 445
446 446 See the :duref:`reST reference for substitutions &lt;substitution-definitions&gt;`
447 447 for details.
448 448
449 449 If you want to use some substitutions for all documents, put them into
450 450 :confval:`rst_prolog` or put them into a separate file and include it into all
451 451 documents you want to use them in, using the :rst:dir:`include` directive. (Be
452 452 sure to give the include file a file name extension differing from that of other
453 453 source files, to avoid Sphinx finding it as a standalone document.)
454 454
455 455 Sphinx defines some default substitutions, see :ref:`default-substitutions`.
456 456
457 457
458 458 Comments
459 459 --------
460 460
461 461 Every explicit markup block which isn't a valid markup construct (like the
462 462 footnotes above) is regarded as a comment (:duref:`ref &lt;comments&gt;`). For
463 463 example::
464 464
465 465 .. This is a comment.
466 466
467 467 You can indent text after a comment start to form multiline comments::
468 468
469 469 ..
470 470 This whole indented block
471 471 is a comment.
472 472
473 473 Still in the comment.
474 474
475 475
476 476 Source encoding
477 477 ---------------
478 478
479 479 Since the easiest way to include special characters like em dashes or copyright
480 480 signs in reST is to directly write them as Unicode characters, one has to
481 481 specify an encoding. Sphinx assumes source files to be encoded in UTF-8 by
482 482 default; you can change this with the :confval:`source_encoding` config value.
483 483
484 484
485 485 Gotchas
486 486 -------
487 487
488 488 There are some problems one commonly runs into while authoring reST documents:
489 489
490 490 * **Separation of inline markup:** As said above, inline markup spans must be
491 491 separated from the surrounding text by non-word characters, you have to use a
492 492 backslash-escaped space to get around that. See `the reference
493 493 &lt;http://docutils.sf.net/docs/ref/rst/restructuredtext.html#inline-markup&gt;`_
494 494 for the details.
495 495
496 496 * **No nested inline markup:** Something like ``*see :func:`foo`*`` is not
497 497 possible.
498 498
499 499
500 500 .. rubric:: Footnotes
501 501
502 502 .. [1] When the default domain contains a :rst:dir:`class` directive, this directive
503 503 will be shadowed. Therefore, Sphinx re-exports it as :rst:dir:`rst-class`.
504 504 </textarea></form>
505 505
506 506 <script>
507 507 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
508 508 lineNumbers: true,
509 509 });
510 510 </script>
511 511 <p>
512 512 The <code>python</code> mode will be used for highlighting blocks
513 513 containing Python/IPython terminal sessions: blocks starting with
514 514 <code>&gt;&gt;&gt;</code> (for Python) or <code>In [num]:</code> (for
515 515 IPython).
516 516
517 517 Further, the <code>stex</code> mode will be used for highlighting
518 518 blocks containing LaTex code.
519 519 </p>
520 520
521 521 <p><strong>MIME types defined:</strong> <code>text/x-rst</code>.</p>
522 522 </body>
523 523 </html>
524
@@ -1,173 +1,173 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: Ruby mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="../../addon/edit/matchbrackets.js"></script>
9 9 <script src="ruby.js"></script>
10 10 <style>
11 11 .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
12 12 .cm-s-default span.cm-arrow { color: red; }
13 13 </style>
14 14 <link rel="stylesheet" href="../../doc/docs.css">
15 15 </head>
16 16 <body>
17 17 <h1>CodeMirror: Ruby mode</h1>
18 18 <form><textarea id="code" name="code">
19 19 # Code from http://sandbox.mc.edu/~bennet/ruby/code/poly_rb.html
20 20 #
21 21 # This program evaluates polynomials. It first asks for the coefficients
22 22 # of a polynomial, which must be entered on one line, highest-order first.
23 23 # It then requests values of x and will compute the value of the poly for
24 24 # each x. It will repeatly ask for x values, unless you the user enters
25 25 # a blank line. It that case, it will ask for another polynomial. If the
26 26 # user types quit for either input, the program immediately exits.
27 27 #
28 28
29 29 #
30 30 # Function to evaluate a polynomial at x. The polynomial is given
31 31 # as a list of coefficients, from the greatest to the least.
32 32 def polyval(x, coef)
33 33 sum = 0
34 34 coef = coef.clone # Don't want to destroy the original
35 35 while true
36 36 sum += coef.shift # Add and remove the next coef
37 37 break if coef.empty? # If no more, done entirely.
38 38 sum *= x # This happens the right number of times.
39 39 end
40 40 return sum
41 41 end
42 42
43 43 #
44 44 # Function to read a line containing a list of integers and return
45 45 # them as an array of integers. If the string conversion fails, it
46 46 # throws TypeError. If the input line is the word 'quit', then it
47 47 # converts it to an end-of-file exception
48 48 def readints(prompt)
49 49 # Read a line
50 50 print prompt
51 51 line = readline.chomp
52 52 raise EOFError.new if line == 'quit' # You can also use a real EOF.
53
53
54 54 # Go through each item on the line, converting each one and adding it
55 55 # to retval.
56 56 retval = [ ]
57 57 for str in line.split(/\s+/)
58 58 if str =~ /^\-?\d+$/
59 59 retval.push(str.to_i)
60 60 else
61 61 raise TypeError.new
62 62 end
63 63 end
64 64
65 65 return retval
66 66 end
67 67
68 68 #
69 69 # Take a coeff and an exponent and return the string representation, ignoring
70 70 # the sign of the coefficient.
71 71 def term_to_str(coef, exp)
72 72 ret = ""
73 73
74 74 # Show coeff, unless it's 1 or at the right
75 75 coef = coef.abs
76 76 ret = coef.to_s unless coef == 1 && exp > 0
77 77 ret += "x" if exp > 0 # x if exponent not 0
78 78 ret += "^" + exp.to_s if exp > 1 # ^exponent, if > 1.
79 79
80 80 return ret
81 81 end
82 82
83 83 #
84 84 # Create a string of the polynomial in sort-of-readable form.
85 85 def polystr(p)
86 86 # Get the exponent of first coefficient, plus 1.
87 87 exp = p.length
88 88
89 89 # Assign exponents to each term, making pairs of coeff and exponent,
90 90 # Then get rid of the zero terms.
91 91 p = (p.map { |c| exp -= 1; [ c, exp ] }).select { |p| p[0] != 0 }
92 92
93 93 # If there's nothing left, it's a zero
94 94 return "0" if p.empty?
95 95
96 96 # *** Now p is a non-empty list of [ coef, exponent ] pairs. ***
97 97
98 98 # Convert the first term, preceded by a "-" if it's negative.
99 99 result = (if p[0][0] < 0 then "-" else "" end) + term_to_str(*p[0])
100 100
101 101 # Convert the rest of the terms, in each case adding the appropriate
102 # + or - separating them.
102 # + or - separating them.
103 103 for term in p[1...p.length]
104 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 106 term_to_str(*term)
107 107 end
108 108
109 109 return result
110 110 end
111
111
112 112 #
113 113 # Run until some kind of endfile.
114 114 begin
115 115 # Repeat until an exception or quit gets us out.
116 116 while true
117 117 # Read a poly until it works. An EOF will except out of the
118 118 # program.
119 119 print "\n"
120 120 begin
121 121 poly = readints("Enter a polynomial coefficients: ")
122 122 rescue TypeError
123 123 print "Try again.\n"
124 124 retry
125 125 end
126 126 break if poly.empty?
127 127
128 128 # Read and evaluate x values until the user types a blank line.
129 129 # Again, an EOF will except out of the pgm.
130 130 while true
131 131 # Request an integer.
132 132 print "Enter x value or blank line: "
133 133 x = readline.chomp
134 134 break if x == ''
135 135 raise EOFError.new if x == 'quit'
136 136
137 137 # If it looks bad, let's try again.
138 138 if x !~ /^\-?\d+$/
139 139 print "That doesn't look like an integer. Please try again.\n"
140 140 next
141 141 end
142 142
143 143 # Convert to an integer and print the result.
144 144 x = x.to_i
145 145 print "p(x) = ", polystr(poly), "\n"
146 146 print "p(", x, ") = ", polyval(x, poly), "\n"
147 147 end
148 148 end
149 149 rescue EOFError
150 150 print "\n=== EOF ===\n"
151 151 rescue Interrupt, SignalException
152 152 print "\n=== Interrupted ===\n"
153 153 else
154 154 print "--- Bye ---\n"
155 155 end
156 156 </textarea></form>
157 157 <script>
158 158 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
159 159 mode: "text/x-ruby",
160 160 tabMode: "indent",
161 161 matchBrackets: true,
162 162 indentUnit: 4
163 163 });
164 164 </script>
165 165
166 166 <p><strong>MIME types defined:</strong> <code>text/x-ruby</code>.</p>
167 167
168 168 <p>Development of the CodeMirror Ruby mode was kindly sponsored
169 169 by <a href="http://ubalo.com/">Ubalo</a>, who hold
170 170 the <a href="LICENSE">license</a>.</p>
171 171
172 172 </body>
173 173 </html>
@@ -1,65 +1,65 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: Scheme mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="scheme.js"></script>
9 9 <style>.CodeMirror {background: #f8f8f8;}</style>
10 10 <link rel="stylesheet" href="../../doc/docs.css">
11 11 </head>
12 12 <body>
13 13 <h1>CodeMirror: Scheme mode</h1>
14 14 <form><textarea id="code" name="code">
15 15 ; See if the input starts with a given symbol.
16 16 (define (match-symbol input pattern)
17 17 (cond ((null? (remain input)) #f)
18 ((eqv? (car (remain input)) pattern) (r-cdr input))
19 (else #f)))
18 ((eqv? (car (remain input)) pattern) (r-cdr input))
19 (else #f)))
20 20
21 21 ; Allow the input to start with one of a list of patterns.
22 22 (define (match-or input pattern)
23 23 (cond ((null? pattern) #f)
24 ((match-pattern input (car pattern)))
25 (else (match-or input (cdr pattern)))))
24 ((match-pattern input (car pattern)))
25 (else (match-or input (cdr pattern)))))
26 26
27 27 ; Allow a sequence of patterns.
28 28 (define (match-seq input pattern)
29 29 (if (null? pattern)
30 30 input
31 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 34 ; Match with the pattern but no problem if it does not match.
35 35 (define (match-opt input pattern)
36 36 (let ((match (match-pattern input (car pattern))))
37 37 (if match match input)))
38 38
39 39 ; Match anything (other than '()), until pattern is found. The rather
40 40 ; clumsy form of requiring an ending pattern is needed to decide where
41 41 ; the end of the match is. If none is given, this will match the rest
42 42 ; of the sentence.
43 43 (define (match-any input pattern)
44 44 (cond ((null? (remain input)) #f)
45 ((null? pattern) (f-cons (remain input) (clear-remain input)))
46 (else
47 (let ((accum-any (collector)))
48 (define (match-pattern-any input pattern)
49 (cond ((null? (remain input)) #f)
50 (else (accum-any (car (remain input)))
51 (cond ((match-pattern (r-cdr input) pattern))
52 (else (match-pattern-any (r-cdr input) pattern))))))
53 (let ((retval (match-pattern-any input (car pattern))))
54 (if retval
55 (f-cons (accum-any) retval)
56 #f))))))
45 ((null? pattern) (f-cons (remain input) (clear-remain input)))
46 (else
47 (let ((accum-any (collector)))
48 (define (match-pattern-any input pattern)
49 (cond ((null? (remain input)) #f)
50 (else (accum-any (car (remain input)))
51 (cond ((match-pattern (r-cdr input) pattern))
52 (else (match-pattern-any (r-cdr input) pattern))))))
53 (let ((retval (match-pattern-any input (car pattern))))
54 (if retval
55 (f-cons (accum-any) retval)
56 #f))))))
57 57 </textarea></form>
58 58 <script>
59 59 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
60 60 </script>
61 61
62 62 <p><strong>MIME types defined:</strong> <code>text/x-scheme</code>.</p>
63 63
64 64 </body>
65 65 </html>
@@ -1,57 +1,57 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: Smalltalk mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="../../addon/edit/matchbrackets.js"></script>
9 9 <script src="smalltalk.js"></script>
10 10 <link rel="stylesheet" href="../../doc/docs.css">
11 11 <style>
12 12 .CodeMirror {border: 2px solid #dee; border-right-width: 10px;}
13 13 .CodeMirror-gutter {border: none; background: #dee;}
14 14 .CodeMirror-gutter pre {color: white; font-weight: bold;}
15 15 </style>
16 16 </head>
17 17 <body>
18 18 <h1>CodeMirror: Smalltalk mode</h1>
19 19
20 20 <form><textarea id="code" name="code">
21 "
21 "
22 22 This is a test of the Smalltalk code
23 23 "
24 24 Seaside.WAComponent subclass: #MyCounter [
25 25 | count |
26 26 MyCounter class &gt;&gt; canBeRoot [ ^true ]
27 27
28 28 initialize [
29 29 super initialize.
30 30 count := 0.
31 31 ]
32 32 states [ ^{ self } ]
33 33 renderContentOn: html [
34 34 html heading: count.
35 35 html anchor callback: [ count := count + 1 ]; with: '++'.
36 36 html space.
37 37 html anchor callback: [ count := count - 1 ]; with: '--'.
38 38 ]
39 39 ]
40 40
41 41 MyCounter registerAsApplication: 'mycounter'
42 42 </textarea></form>
43 43
44 44 <script>
45 45 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
46 46 lineNumbers: true,
47 47 matchBrackets: true,
48 48 mode: "text/x-stsrc",
49 49 indentUnit: 4
50 50 });
51 51 </script>
52 52
53 53 <p>Simple Smalltalk mode.</p>
54 54
55 55 <p><strong>MIME types defined:</strong> <code>text/x-stsrc</code>.</p>
56 56 </body>
57 57 </html>
@@ -1,126 +1,126 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: Smarty mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="smarty.js"></script>
9 9 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
10 10 <link rel="stylesheet" href="../../doc/docs.css">
11 11 </head>
12 12 <body>
13 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 16 <form><textarea id="code" name="code">
17 17 {extends file="parent.tpl"}
18 18 {include file="template.tpl"}
19 19
20 20 {* some example Smarty content *}
21 21 {if isset($name) && $name == 'Blog'}
22 22 This is a {$var}.
23 23 {$integer = 451}, {$array[] = "a"}, {$stringvar = "string"}
24 24 {assign var='bob' value=$var.prop}
25 25 {elseif $name == $foo}
26 26 {function name=menu level=0}
27 27 {foreach $data as $entry}
28 28 {if is_array($entry)}
29 29 - {$entry@key}
30 30 {menu data=$entry level=$level+1}
31 31 {else}
32 32 {$entry}
33 33 {/if}
34 34 {/foreach}
35 35 {/function}
36 36 {/if}</textarea></form>
37 37
38 38 <script>
39 39 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
40 40 lineNumbers: true,
41 41 mode: "smarty"
42 42 });
43 43 </script>
44 44
45 45 <br />
46 46
47 <h3>Smarty 2, custom delimiters</h3>
47 <h3>Smarty 2, custom delimiters</h3>
48 48 <form><textarea id="code2" name="code2">
49 49 {--extends file="parent.tpl"--}
50 50 {--include file="template.tpl"--}
51 51
52 52 {--* some example Smarty content *--}
53 53 {--if isset($name) && $name == 'Blog'--}
54 54 This is a {--$var--}.
55 55 {--$integer = 451--}, {--$array[] = "a"--}, {--$stringvar = "string"--}
56 56 {--assign var='bob' value=$var.prop--}
57 57 {--elseif $name == $foo--}
58 58 {--function name=menu level=0--}
59 59 {--foreach $data as $entry--}
60 60 {--if is_array($entry)--}
61 61 - {--$entry@key--}
62 62 {--menu data=$entry level=$level+1--}
63 63 {--else--}
64 64 {--$entry--}
65 65 {--/if--}
66 66 {--/foreach--}
67 67 {--/function--}
68 68 {--/if--}</textarea></form>
69 69
70 70 <script>
71 71 var editor = CodeMirror.fromTextArea(document.getElementById("code2"), {
72 72 lineNumbers: true,
73 73 mode: {
74 74 name: "smarty",
75 75 leftDelimiter: "{--",
76 76 rightDelimiter: "--}"
77 77 }
78 78 });
79 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 86 Nested tags {$foo={counter one=1 two={inception}}+3} are now valid in Smarty 3.
87 87
88 88 <script>
89 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 92 </script>
93 93
94 94 {assign var=foo value=[1,2,3]}
95 95 {assign var=foo value=['y'=>'yellow','b'=>'blue']}
96 96 {assign var=foo value=[1,[9,8],3]}
97 97
98 98 {$foo=$bar+2} {* a comment *}
99 99 {$foo.bar=1} {* another comment *}
100 100 {$foo = myfunct(($x+$y)*3)}
101 101 {$foo = strlen($bar)}
102 102 {$foo.bar.baz=1}, {$foo[]=1}
103 103
104 104 Smarty "dot" syntax (note: embedded {} are used to address ambiguities):
105 105
106 106 {$foo.a.b.c} => $foo['a']['b']['c']
107 107 {$foo.a.$b.c} => $foo['a'][$b]['c']
108 108 {$foo.a.{$b+4}.c} => $foo['a'][$b+4]['c']
109 109 {$foo.a.{$b.c}} => $foo['a'][$b['c']]
110 110
111 111 {$object->method1($x)->method2($y)}</textarea>
112 112
113 <script>
114 var editor = CodeMirror.fromTextArea(document.getElementById("code3"), {
115 lineNumbers: true,
116 mode: "smarty",
117 smartyVersion: 3
118 });
119 </script>
113 <script>
114 var editor = CodeMirror.fromTextArea(document.getElementById("code3"), {
115 lineNumbers: true,
116 mode: "smarty",
117 smartyVersion: 3
118 });
119 </script>
120 120
121 121
122 122 <p>A plain text/Smarty version 2 or 3 mode, which allows for custom delimiter tags.</p>
123 123
124 124 <p><strong>MIME types defined:</strong> <code>text/x-smarty</code></p>
125 125 </body>
126 126 </html>
@@ -1,68 +1,68 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>SQL Mode for CodeMirror</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css" />
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="sql.js"></script>
9 9 <style>
10 10 .CodeMirror {
11 11 border-top: 1px solid black;
12 12 border-bottom: 1px solid black;
13 13 }
14 14 </style>
15 15 <link rel="stylesheet" href="../../doc/docs.css">
16 16 <script>
17 17 var init = function() {
18 18 var mime = 'text/x-mariadb';
19 19
20 20 // get mime type
21 21 if (window.location.href.indexOf('mime=') > -1) {
22 22 mime = window.location.href.substr(window.location.href.indexOf('mime=') + 5);
23 23 }
24 24
25 25 window.editor = CodeMirror.fromTextArea(document.getElementById('code'), {
26 26 mode: mime,
27 27 indentWithTabs: true,
28 28 smartIndent: true,
29 29 lineNumbers: true,
30 30 matchBrackets : true,
31 31 autofocus: true
32 32 });
33 33 };
34 34 </script>
35 35 </head>
36 36 <body onload="init();">
37 37 <h1>SQL Mode for CodeMirror</h1>
38 38 <form>
39 39 <textarea id="code" name="code">-- SQL Mode for CodeMirror
40 40 SELECT SQL_NO_CACHE DISTINCT
41 @var1 AS `val1`, @'val2', @global.'sql_mode',
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`,
44 DATE '1994-01-01' AS `sql_date`, { T "1994-01-01" } AS `odbc_date`,
45 'my string', _utf8'your string', N'her string',
41 @var1 AS `val1`, @'val2', @global.'sql_mode',
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`,
44 DATE '1994-01-01' AS `sql_date`, { T "1994-01-01" } AS `odbc_date`,
45 'my string', _utf8'your string', N'her string',
46 46 TRUE, FALSE, UNKNOWN
47 FROM DUAL
48 -- space needed after '--'
49 # 1 line comment
50 /* multiline
51 comment! */
52 LIMIT 1 OFFSET 0;
47 FROM DUAL
48 -- space needed after '--'
49 # 1 line comment
50 /* multiline
51 comment! */
52 LIMIT 1 OFFSET 0;
53 53 </textarea>
54 54 </form>
55 <p><strong>MIME types defined:</strong>
55 <p><strong>MIME types defined:</strong>
56 56 <code><a href="?mime=text/x-sql">text/x-sql</a></code>,
57 57 <code><a href="?mime=text/x-mysql">text/x-mysql</a></code>,
58 58 <code><a href="?mime=text/x-mariadb">text/x-mariadb</a></code>,
59 59 <code><a href="?mime=text/x-cassandra">text/x-cassandra</a></code>,
60 60 <code><a href="?mime=text/x-plsql">text/x-plsql</a></code>.
61 61 </p>
62 62 <p>
63 63 <strong>Tests:</strong>
64 64 <a href="../../test/index.html#sql_*">normal</a>,
65 65 <a href="../../test/index.html#verbose,sql_*">verbose</a>.
66 66 </p>
67 67 </body>
68 68 </html>
@@ -1,98 +1,98 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: sTeX mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="stex.js"></script>
9 9 <style>.CodeMirror {background: #f8f8f8;}</style>
10 10 <link rel="stylesheet" href="../../doc/docs.css">
11 11 </head>
12 12 <body>
13 13 <h1>CodeMirror: sTeX mode</h1>
14 14 <form><textarea id="code" name="code">
15 15 \begin{module}[id=bbt-size]
16 16 \importmodule[balanced-binary-trees]{balanced-binary-trees}
17 17 \importmodule[\KWARCslides{dmath/en/cardinality}]{cardinality}
18 18
19 19 \begin{frame}
20 20 \frametitle{Size Lemma for Balanced Trees}
21 21 \begin{itemize}
22 22 \item
23 \begin{assertion}[id=size-lemma,type=lemma]
24 Let $G=\tup{V,E}$ be a \termref[cd=binary-trees]{balanced binary tree}
23 \begin{assertion}[id=size-lemma,type=lemma]
24 Let $G=\tup{V,E}$ be a \termref[cd=binary-trees]{balanced binary tree}
25 25 of \termref[cd=graph-depth,name=vertex-depth]{depth}$n>i$, then the set
26 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 28 \termref[cd=graph-depth,name=vertex-depth]{depth} $i$ has
29 29 \termref[cd=cardinality,name=cardinality]{cardinality} $\power2i$.
30 30 \end{assertion}
31 31 \item
32 32 \begin{sproof}[id=size-lemma-pf,proofend=,for=size-lemma]{via induction over the depth $i$.}
33 33 \begin{spfcases}{We have to consider two cases}
34 34 \begin{spfcase}{$i=0$}
35 35 \begin{spfstep}[display=flow]
36 36 then $\livar{V}i=\set{\livar{v}r}$, where $\livar{v}r$ is the root, so
37 37 $\eq{\card{\livar{V}0},\card{\set{\livar{v}r}},1,\power20}$.
38 38 \end{spfstep}
39 39 \end{spfcase}
40 40 \begin{spfcase}{$i>0$}
41 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 43 \begin{justification}[method=byIH](IH)\end{justification}
44 44 \end{spfstep}
45 45 \begin{spfstep}
46 46 By the \begin{justification}[method=byDef]definition of a binary
47 47 tree\end{justification}, each $\inset{v}{\livar{V}{i-1}}$ is a leaf or has
48 48 two children that are at depth $i$.
49 49 \end{spfstep}
50 50 \begin{spfstep}
51 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 52 leaves.
53 53 \end{spfstep}
54 54 \begin{spfstep}[type=conclusion]
55 55 Thus $\eq{\card{\livar{V}i},{\atimes[cdot]{2,\card{\livar{V}{i-1}}}},{\atimes[cdot]{2,\power2{i-1}}},\power2i}$.
56 56 \end{spfstep}
57 57 \end{spfcase}
58 58 \end{spfcases}
59 59 \end{sproof}
60 \item
61 \begin{assertion}[id=fbbt,type=corollary]
60 \item
61 \begin{assertion}[id=fbbt,type=corollary]
62 62 A fully balanced tree of depth $d$ has $\power2{d+1}-1$ nodes.
63 63 \end{assertion}
64 64 \item
65 65 \begin{sproof}[for=fbbt,id=fbbt-pf]{}
66 66 \begin{spfstep}
67 67 Let $\defeq{G}{\tup{V,E}}$ be a fully balanced tree
68 68 \end{spfstep}
69 69 \begin{spfstep}
70 70 Then $\card{V}=\Sumfromto{i}1d{\power2i}= \power2{d+1}-1$.
71 71 \end{spfstep}
72 72 \end{sproof}
73 73 \end{itemize}
74 74 \end{frame}
75 75 \begin{note}
76 76 \begin{omtext}[type=conclusion,for=binary-tree]
77 77 This shows that balanced binary trees grow in breadth very quickly, a consequence of
78 78 this is that they are very shallow (and this compute very fast), which is the essence of
79 79 the next result.
80 80 \end{omtext}
81 81 \end{note}
82 82 \end{module}
83 83
84 %%% Local Variables:
84 %%% Local Variables:
85 85 %%% mode: LaTeX
86 86 %%% TeX-master: "all"
87 87 %%% End: \end{document}
88 88 </textarea></form>
89 89 <script>
90 90 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
91 91 </script>
92 92
93 93 <p><strong>MIME types defined:</strong> <code>text/x-stex</code>.</p>
94 94
95 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 97 </body>
98 98 </html>
@@ -1,129 +1,129 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: Tcl mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="tcl.js"></script>
9 9 <link rel="stylesheet" href="../../theme/night.css">
10 10 <link rel="stylesheet" href="../../doc/docs.css">
11 11 </head>
12 12 <body>
13 13 <h1>CodeMirror: Tcl mode</h1>
14 14 <form><textarea id="code" name="code">
15 15 ##############################################################################################
16 16 ## ## whois.tcl for eggdrop by Ford_Lawnmower irc.geekshed.net #Script-Help ## ##
17 17 ##############################################################################################
18 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 27 ## ## Start Setup. ## ##
28 28 ##############################################################################################
29 29 namespace eval whois {
30 30 ## change cmdchar to the trigger you want to use ## ##
31 31 variable cmdchar "!"
32 32 ## change command to the word trigger you would like to use. ## ##
33 33 ## Keep in mind, This will also change the .chanset +/-command ## ##
34 34 variable command "whois"
35 35 ## change textf to the colors you want for the text. ## ##
36 36 variable textf "\017\00304"
37 37 ## change tagf to the colors you want for tags: ## ##
38 38 variable tagf "\017\002"
39 39 ## Change logo to the logo you want at the start of the line. ## ##
40 40 variable logo "\017\00304\002\[\00306W\003hois\00304\]\017"
41 41 ## Change lineout to the results you want. Valid results are channel users modes topic ## ##
42 42 variable lineout "channel users modes topic"
43 43 ##############################################################################################
44 44 ## ## End Setup. ## ##
45 45 ##############################################################################################
46 46 variable channel ""
47 47 setudef flag $whois::command
48 48 bind pub -|- [string trimleft $whois::cmdchar]${whois::command} whois::list
49 49 bind raw -|- "311" whois::311
50 50 bind raw -|- "312" whois::312
51 51 bind raw -|- "319" whois::319
52 52 bind raw -|- "317" whois::317
53 53 bind raw -|- "313" whois::multi
54 54 bind raw -|- "310" whois::multi
55 55 bind raw -|- "335" whois::multi
56 56 bind raw -|- "301" whois::301
57 57 bind raw -|- "671" whois::multi
58 58 bind raw -|- "320" whois::multi
59 59 bind raw -|- "401" whois::multi
60 60 bind raw -|- "318" whois::318
61 61 bind raw -|- "307" whois::307
62 62 }
63 63 proc whois::311 {from key text} {
64 64 if {[regexp -- {^[^\s]+\s(.+?)\s(.+?)\s(.+?)\s\*\s\:(.+)$} $text wholematch nick ident host realname]} {
65 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 69 proc whois::multi {from key text} {
70 70 if {[regexp {\:(.*)$} $text match $key]} {
71 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 75 proc whois::312 {from key text} {
76 76 regexp {([^\s]+)\s\:} $text match server
77 77 putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Server:${whois::textf} $server"
78 78 }
79 79 proc whois::319 {from key text} {
80 80 if {[regexp {.+\:(.+)$} $text match channels]} {
81 81 putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Channels:${whois::textf} $channels"
82 82 }
83 83 }
84 84 proc whois::317 {from key text} {
85 85 if {[regexp -- {.*\s(\d+)\s(\d+)\s\:} $text wholematch idle signon]} {
86 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 90 proc whois::301 {from key text} {
91 91 if {[regexp {^.+\s[^\s]+\s\:(.*)$} $text match awaymsg]} {
92 92 putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Away:${whois::textf} $awaymsg"
93 93 }
94 94 }
95 95 proc whois::318 {from key text} {
96 96 namespace eval whois {
97 variable channel ""
97 variable channel ""
98 98 }
99 99 variable whois::channel ""
100 100 }
101 101 proc whois::307 {from key text} {
102 102 putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Services:${whois::textf} Registered Nick"
103 103 }
104 104 proc whois::list {nick host hand chan text} {
105 105 if {[lsearch -exact [channel info $chan] "+${whois::command}"] != -1} {
106 106 namespace eval whois {
107 variable channel ""
108 }
107 variable channel ""
108 }
109 109 variable whois::channel $chan
110 110 putserv "WHOIS $text"
111 111 }
112 112 }
113 113 putlog "\002*Loaded* \017\00304\002\[\00306W\003hois\00304\]\017 \002by \
114 114 Ford_Lawnmower irc.GeekShed.net #Script-Help"
115 115 </textarea></form>
116 116 <script>
117 117 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
118 118 tabMode: "indent",
119 theme: "night",
119 theme: "night",
120 120 lineNumbers: true,
121 121 indentUnit: 2,
122 122 mode: "text/x-tcl"
123 123 });
124 124 </script>
125 125
126 126 <p><strong>MIME types defined:</strong> <code>text/x-tcl</code>.</p>
127 127
128 128 </body>
129 129 </html>
@@ -1,142 +1,142 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: TiddlyWiki mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="../../addon/edit/matchbrackets.js"></script>
9 9 <script src="tiddlywiki.js"></script>
10 10 <link rel="stylesheet" href="tiddlywiki.css">
11 11 <link rel="stylesheet" href="../../doc/docs.css">
12 12 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
13 13 </head>
14 14 <body>
15 15 <h1>CodeMirror: TiddlyWiki mode</h1>
16 16
17 17 <div><textarea id="code" name="code">
18 18 !TiddlyWiki Formatting
19 19 * Rendered versions can be found at: http://www.tiddlywiki.com/#Reference
20 20
21 21 |!Option | !Syntax |
22 22 |bold font | ''bold'' |
23 23 |italic type | //italic// |
24 24 |underlined text | __underlined__ |
25 25 |strikethrough text | --strikethrough-- |
26 26 |superscript text | super^^script^^ |
27 27 |subscript text | sub~~script~~ |
28 28 |highlighted text | @@highlighted@@ |
29 29 |preformatted text | {{{preformatted}}} |
30 30
31 31 !Block Elements
32 32 <<<
33 33 !Heading 1
34 34
35 35 !!Heading 2
36 36
37 37 !!!Heading 3
38 38
39 39 !!!!Heading 4
40 40
41 41 !!!!!Heading 5
42 42 <<<
43 43
44 44 !!Lists
45 45 <<<
46 46 * unordered list, level 1
47 47 ** unordered list, level 2
48 48 *** unordered list, level 3
49 49
50 50 # ordered list, level 1
51 51 ## ordered list, level 2
52 52 ### unordered list, level 3
53 53
54 54 ; definition list, term
55 55 : definition list, description
56 56 <<<
57 57
58 58 !!Blockquotes
59 59 <<<
60 60 > blockquote, level 1
61 61 >> blockquote, level 2
62 62 >>> blockquote, level 3
63 63
64 64 > blockquote
65 65 <<<
66 66
67 67 !!Preformatted Text
68 68 <<<
69 69 {{{
70 70 preformatted (e.g. code)
71 71 }}}
72 72 <<<
73 73
74 74 !!Code Sections
75 75 <<<
76 76 {{{
77 77 Text style code
78 78 }}}
79 79
80 80 //{{{
81 81 JS styled code. TiddlyWiki mixed mode should support highlighter switching in the future.
82 82 //}}}
83 83
84 84 <!--{{{-->
85 85 XML styled code. TiddlyWiki mixed mode should support highlighter switching in the future.
86 86 <!--}}}-->
87 87 <<<
88 88
89 89 !!Tables
90 90 <<<
91 91 |CssClass|k
92 92 |!heading column 1|!heading column 2|
93 93 |row 1, column 1|row 1, column 2|
94 94 |row 2, column 1|row 2, column 2|
95 95 |>|COLSPAN|
96 96 |ROWSPAN| ... |
97 97 |~| ... |
98 98 |CssProperty:value;...| ... |
99 99 |caption|c
100 100
101 101 ''Annotation:''
102 102 * The {{{>}}} marker creates a "colspan", causing the current cell to merge with the one to the right.
103 103 * The {{{~}}} marker creates a "rowspan", causing the current cell to merge with the one above.
104 104 <<<
105 105 !!Images /% TODO %/
106 106 cf. [[TiddlyWiki.com|http://www.tiddlywiki.com/#EmbeddedImages]]
107 107
108 108 !Hyperlinks
109 109 * [[WikiWords|WikiWord]] are automatically transformed to hyperlinks to the respective tiddler
110 110 ** the automatic transformation can be suppressed by preceding the respective WikiWord with a tilde ({{{~}}}): {{{~WikiWord}}}
111 111 * [[PrettyLinks]] are enclosed in square brackets and contain the desired tiddler name: {{{[[tiddler name]]}}}
112 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 114 !Custom Styling
115 115 * {{{@@CssProperty:value;CssProperty:value;...@@}}}<br>''N.B.:'' CSS color definitions should use lowercase letters to prevent the inadvertent creation of WikiWords.
116 116 * <html><code>{{customCssClass{...}}}</code></html>
117 117 * raw HTML can be inserted by enclosing the respective code in HTML tags: {{{<html> ... </html>}}}
118 118
119 119 !Special Markers
120 120 * {{{<br>}}} forces a manual line break
121 121 * {{{----}}} creates a horizontal ruler
122 122 * [[HTML entities|http://www.tiddlywiki.com/#HtmlEntities]]
123 123 * [[HTML entities local|HtmlEntities]]
124 124 * {{{<<macroName>>}}} calls the respective [[macro|Macros]]
125 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 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 127 </textarea></div>
128 128
129 129 <script>
130 130 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
131 mode: 'tiddlywiki',
131 mode: 'tiddlywiki',
132 132 lineNumbers: true,
133 133 enterMode: 'keep',
134 134 matchBrackets: true
135 135 });
136 136 </script>
137 137
138 138 <p>TiddlyWiki mode supports a single configuration.</p>
139 139
140 140 <p><strong>MIME types defined:</strong> <code>text/x-tiddlywiki</code>.</p>
141 141 </body>
142 142 </html>
@@ -1,81 +1,81 b''
1 1 <html xmlns="http://www.w3.org/1999/xhtml">
2 2 <head>
3 3 <meta charset="utf-8">
4 4 <title>CodeMirror: Tiki wiki mode</title>
5 5 <link rel="stylesheet" href="../../lib/codemirror.css">
6 6 <script src="../../lib/codemirror.js"></script>
7 7 <script src="tiki.js"></script>
8 8 <link rel="stylesheet" href="tiki.css">
9 9 <link rel="stylesheet" href="../../doc/docs.css">
10 10 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
11 11 </head>
12 12 <body style="padding: 20px;">
13 13 <h1>CodeMirror: Tiki wiki mode</h1>
14 14
15 15 <div><textarea id="code" name="code">
16 16 Headings
17 17 !Header 1
18 18 !!Header 2
19 19 !!!Header 3
20 20 !!!!Header 4
21 21 !!!!!Header 5
22 22 !!!!!!Header 6
23 23
24 24 Styling
25 25 -=titlebar=-
26 26 ^^ Box on multi
27 27 lines
28 28 of content^^
29 29 __bold__
30 30 ''italic''
31 31 ===underline===
32 32 ::center::
33 33 --Line Through--
34 34
35 35 Operators
36 36 ~np~No parse~/np~
37 37
38 38 Link
39 39 [link|desc|nocache]
40 40
41 41 Wiki
42 42 ((Wiki))
43 43 ((Wiki|desc))
44 44 ((Wiki|desc|timeout))
45 45
46 46 Table
47 47 ||row1 col1|row1 col2|row1 col3
48 48 row2 col1|row2 col2|row2 col3
49 49 row3 col1|row3 col2|row3 col3||
50 50
51 51 Lists:
52 52 *bla
53 53 **bla-1
54 54 ++continue-bla-1
55 55 ***bla-2
56 56 ++continue-bla-1
57 57 *bla
58 58 +continue-bla
59 59 #bla
60 60 ** tra-la-la
61 61 +continue-bla
62 62 #bla
63 63
64 64 Plugin (standard):
65 65 {PLUGIN(attr="my attr")}
66 66 Plugin Body
67 67 {PLUGIN}
68 68
69 69 Plugin (inline):
70 70 {plugin attr="my attr"}
71 71 </textarea></div>
72 72
73 73 <script type="text/javascript">
74 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
75 mode: 'tiki',
74 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
75 mode: 'tiki',
76 76 lineNumbers: true
77 77 });
78 78 </script>
79 79
80 80 </body>
81 81 </html>
@@ -1,26 +1,26 b''
1 1 .cm-tw-syntaxerror {
2 color: #FFF;
3 background-color: #900;
2 color: #FFF;
3 background-color: #900;
4 4 }
5 5
6 6 .cm-tw-deleted {
7 text-decoration: line-through;
7 text-decoration: line-through;
8 8 }
9 9
10 10 .cm-tw-header5 {
11 font-weight: bold;
11 font-weight: bold;
12 12 }
13 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 17 .cm-tw-box {
18 border-top-width: 0px ! important;
19 border-style: solid;
20 border-width: 1px;
21 border-color: inherit;
18 border-top-width: 0px ! important;
19 border-style: solid;
20 border-width: 1px;
21 border-color: inherit;
22 22 }
23 23
24 24 .cm-tw-underline {
25 text-decoration: underline;
26 } No newline at end of file
25 text-decoration: underline;
26 }
@@ -1,39 +1,39 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: Turtle mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="turtle.js"></script>
9 9 <style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
10 10 <link rel="stylesheet" href="../../doc/docs.css">
11 11 </head>
12 12 <body>
13 13 <h1>CodeMirror: Turtle mode</h1>
14 14 <form><textarea id="code" name="code">
15 15 @prefix foaf: <http://xmlns.com/foaf/0.1/> .
16 16 @prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
17 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 20 a foaf:Person;
21 21 foaf:interest <http://www.w3.org/2000/01/sw/>;
22 22 foaf:based_near [
23 23 geo:lat "34.0736111" ;
24 24 geo:lon "-118.3994444"
25 25 ]
26 26
27 27 </textarea></form>
28 28 <script>
29 29 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
30 30 mode: "text/turtle",
31 31 tabMode: "indent",
32 32 matchBrackets: true
33 33 });
34 34 </script>
35 35
36 36 <p><strong>MIME types defined:</strong> <code>text/turtle</code>.</p>
37 37
38 38 </body>
39 39 </html>
@@ -1,88 +1,88 b''
1 1 <html>
2 2 <head>
3 3 <meta charset="utf-8">
4 4 <title>CodeMirror: VB.NET mode</title>
5 5 <link rel="stylesheet" href="../../lib/codemirror.css">
6 6 <script src="../../lib/codemirror.js"></script>
7 7 <script src="vb.js"></script>
8 8 <link rel="stylesheet" href="../../doc/docs.css">
9 9 <link href="http://fonts.googleapis.com/css?family=Inconsolata" rel="stylesheet" type="text/css">
10 10 <style>
11 11 .CodeMirror {border: 1px solid #aaa; height:210px; height: auto;}
12 12 .CodeMirror-scroll { overflow-x: auto; overflow-y: hidden;}
13 13 .CodeMirror pre { font-family: Inconsolata; font-size: 14px}
14 </style>
14 </style>
15 15 <script type="text/javascript" src="../../addon/runmode/runmode.js"></script>
16 16 </head>
17 17 <body onload="init()">
18 18 <h1>CodeMirror: VB.NET mode</h1>
19 19 <script type="text/javascript">
20 20 function test(golden, text) {
21 21 var ok = true;
22 22 var i = 0;
23 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 25 var result = [String(token), String(style)];
26 26 if (golden[i][0] != result[0] || golden[i][1] != result[1]){
27 27 return "Error, expected: " + String(golden[i]) + ", got: " + String(result);
28 28 ok = false;
29 29 }
30 30 i++;
31 31 }
32 CodeMirror.runMode(text, "text/x-vb",callback);
32 CodeMirror.runMode(text, "text/x-vb",callback);
33 33
34 34 if (ok) return "Tests OK";
35 35 }
36 36 function testTypes() {
37 37 var golden = [['Integer','keyword'],[' ','null'],['Float','keyword']]
38 38 var text = "Integer Float";
39 39 return test(golden,text);
40 40 }
41 41 function testIf(){
42 42 var golden = [['If','keyword'],[' ','null'],['True','keyword'],[' ','null'],['End','keyword'],[' ','null'],['If','keyword']];
43 43 var text = 'If True End If';
44 44 return test(golden, text);
45 45 }
46 46 function testDecl(){
47 47 var golden = [['Dim','keyword'],[' ','null'],['x','variable'],[' ','null'],['as','keyword'],[' ','null'],['Integer','keyword']];
48 48 var text = 'Dim x as Integer';
49 49 return test(golden, text);
50 50 }
51 51 function testAll(){
52 52 var result = "";
53 53
54 54 result += testTypes() + "\n";
55 55 result += testIf() + "\n";
56 56 result += testDecl() + "\n";
57 57 return result;
58 58
59 59 }
60 60 function initText(editor) {
61 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 62 editor.setValue(content);
63 63 for (var i =0; i< editor.lineCount(); i++) editor.indentLine(i);
64 64 }
65 65 function init() {
66 66 editor = CodeMirror.fromTextArea(document.getElementById("solution"), {
67 67 lineNumbers: true,
68 68 mode: "text/x-vb",
69 69 readOnly: false,
70 70 tabMode: "shift"
71 71 });
72 72 runTest();
73 73 }
74 74 function runTest() {
75 document.getElementById('testresult').innerHTML = testAll();
75 document.getElementById('testresult').innerHTML = testAll();
76 76 initText(editor);
77
77
78 78 }
79 79 </script>
80 80
81 81
82 82 <div id="edit">
83 83 <textarea style="width:95%;height:200px;padding:5px;" name="solution" id="solution" ></textarea>
84 84 </div>
85 85 <pre id="testresult"></pre>
86 86 <p>MIME type defined: <code>text/x-vb</code>.</p>
87 87
88 88 </body></html>
@@ -1,42 +1,41 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: VBScript mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="vbscript.js"></script>
9 9 <link rel="stylesheet" href="../../doc/docs.css">
10 10 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
11 11 </head>
12 12 <body>
13 13 <h1>CodeMirror: VBScript mode</h1>
14 14
15 15 <div><textarea id="code" name="code">
16 16 ' Pete Guhl
17 17 ' 03-04-2012
18 18 '
19 19 ' Basic VBScript support for codemirror2
20 20
21 21 Const ForReading = 1, ForWriting = 2, ForAppending = 8
22 22
23 23 Call Sub020_PostBroadcastToUrbanAirship(strUserName, strPassword, intTransmitID, strResponse)
24 24
25 25 If Not IsNull(strResponse) AND Len(strResponse) = 0 Then
26 boolTransmitOkYN = False
26 boolTransmitOkYN = False
27 27 Else
28 ' WScript.Echo "Oh Happy Day! Oh Happy DAY!"
29 boolTransmitOkYN = True
28 ' WScript.Echo "Oh Happy Day! Oh Happy DAY!"
29 boolTransmitOkYN = True
30 30 End If
31 31 </textarea></div>
32 32
33 33 <script>
34 34 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
35 35 lineNumbers: true
36 36 });
37 37 </script>
38 38
39 39 <p><strong>MIME types defined:</strong> <code>text/vbscript</code>.</p>
40 40 </body>
41 41 </html>
42
@@ -1,121 +1,121 b''
1 1 <!doctype html>
2 2 <html>
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <title>CodeMirror: Verilog mode</title>
6 6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 7 <script src="../../lib/codemirror.js"></script>
8 8 <script src="verilog.js"></script>
9 9 <link rel="stylesheet" href="../../doc/docs.css">
10 10 <style>.CodeMirror {border: 2px inset #dee;}</style>
11 11 </head>
12 12 <body>
13 13 <h1>CodeMirror: Verilog mode</h1>
14 14
15 15 <form><textarea id="code" name="code">
16 16 /* Verilog demo code */
17 17
18 18 module butterfly
19 19 #(
20 20 parameter WIDTH = 32,
21 21 parameter MWIDTH = 1
22 22 )
23 23 (
24 24 input wire clk,
25 25 input wire rst_n,
26 26 // m_in contains data that passes through this block with no change.
27 27 input wire [MWIDTH-1:0] m_in,
28 28 // The twiddle factor.
29 29 input wire signed [WIDTH-1:0] w,
30 30 // XA
31 31 input wire signed [WIDTH-1:0] xa,
32 32 // XB
33 33 input wire signed [WIDTH-1:0] xb,
34 34 // Set to 1 when new data is present on inputs.
35 35 input wire x_nd,
36 36 // delayed version of m_in.
37 37 output reg [MWIDTH-1:0] m_out,
38 38 // YA = XA + W*XB
39 39 // YB = XA - W*XB
40 40 output wire signed [WIDTH-1:0] ya,
41 41 output wire signed [WIDTH-1:0] yb,
42 42 output reg y_nd,
43 43 output reg error
44 44 );
45 45
46 46 // Set wire to the real and imag parts for convenience.
47 47 wire signed [WIDTH/2-1:0] xa_re;
48 48 wire signed [WIDTH/2-1:0] xa_im;
49 49 assign xa_re = xa[WIDTH-1:WIDTH/2];
50 50 assign xa_im = xa[WIDTH/2-1:0];
51 51 wire signed [WIDTH/2-1: 0] ya_re;
52 52 wire signed [WIDTH/2-1: 0] ya_im;
53 53 assign ya = {ya_re, ya_im};
54 54 wire signed [WIDTH/2-1: 0] yb_re;
55 55 wire signed [WIDTH/2-1: 0] yb_im;
56 56 assign yb = {yb_re, yb_im};
57 57
58 58 // Delayed stuff.
59 59 reg signed [WIDTH/2-1:0] xa_re_z;
60 60 reg signed [WIDTH/2-1:0] xa_im_z;
61 61 // Output of multiplier
62 62 wire signed [WIDTH-1:0] xbw;
63 63 wire signed [WIDTH/2-1:0] xbw_re;
64 64 wire signed [WIDTH/2-1:0] xbw_im;
65 65 assign xbw_re = xbw[WIDTH-1:WIDTH/2];
66 66 assign xbw_im = xbw[WIDTH/2-1:0];
67 67 // Do summing
68 68 // I don't think we should get overflow here because of the
69 69 // size of the twiddle factors.
70 70 // If we do testing should catch it.
71 71 assign ya_re = xa_re_z + xbw_re;
72 72 assign ya_im = xa_im_z + xbw_im;
73 73 assign yb_re = xa_re_z - xbw_re;
74 74 assign yb_im = xa_im_z - xbw_im;
75
75
76 76 // Create the multiply module.
77 77 multiply_complex #(WIDTH) multiply_complex_0
78 78 (.clk(clk),
79 79 .rst_n(rst_n),
80 80 .x(xb),
81 81 .y(w),
82 82 .z(xbw)
83 83 );
84 84
85 85 always @ (posedge clk)
86 86 begin
87 87 if (!rst_n)
88 88 begin
89 89 y_nd <= 1'b0;
90 90 error <= 1'b0;
91 91 end
92 92 else
93 93 begin
94 94 // Set delay for x_nd_old and m.
95 95 y_nd <= x_nd;
96 96 m_out <= m_in;
97 97 if (x_nd)
98 98 begin
99 99 xa_re_z <= xa_re/2;
100 100 xa_im_z <= xa_im/2;
101 101 end
102 102 end
103 103 end
104
104
105 105 endmodule
106 106 </textarea></form>
107 107
108 108 <script>
109 109 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
110 110 lineNumbers: true,
111 111 mode: "text/x-verilog"
112 112 });
113 113 </script>
114 114
115 115 <p>Simple mode that tries to handle Verilog-like languages as well as it
116 116 can. Takes one configuration parameters: <code>keywords</code>, an
117 117 object whose property names are the keywords in the language.</p>
118 118
119 119 <p><strong>MIME types defined:</strong> <code>text/x-verilog</code> (Verilog code).</p>
120 120 </body>
121 121 </html>
@@ -1,221 +1,221 b''
1 <!doctype html>
2 <html>
1 <!doctype html>
2 <html>
3 3 <!--
4 4 /*
5 5 Copyright (C) 2011 by MarkLogic Corporation
6 6 Author: Mike Brevoort <mike@brevoort.com>
7 7
8 8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 9 of this software and associated documentation files (the "Software"), to deal
10 10 in the Software without restriction, including without limitation the rights
11 11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 12 copies of the Software, and to permit persons to whom the Software is
13 13 furnished to do so, subject to the following conditions:
14 14
15 15 The above copyright notice and this permission notice shall be included in
16 16 all copies or substantial portions of the Software.
17 17
18 18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 24 THE SOFTWARE.
25 25 */
26 26 -->
27 <head>
27 <head>
28 28 <meta charset="utf-8">
29 <title>CodeMirror: XQuery mode</title>
30 <link rel="stylesheet" href="../../lib/codemirror.css">
31 <script src="../../lib/codemirror.js"></script>
32 <script src="xquery.js"></script>
33 <link rel="stylesheet" href="../../doc/docs.css">
34 <link rel="stylesheet" href="../../theme/xq-dark.css">
29 <title>CodeMirror: XQuery mode</title>
30 <link rel="stylesheet" href="../../lib/codemirror.css">
31 <script src="../../lib/codemirror.js"></script>
32 <script src="xquery.js"></script>
33 <link rel="stylesheet" href="../../doc/docs.css">
34 <link rel="stylesheet" href="../../theme/xq-dark.css">
35 35 <style type="text/css">
36 .CodeMirror {
37 border-top: 1px solid black; border-bottom: 1px solid black;
38 height:400px;
39 }
40 </style>
41 </head>
42 <body>
43 <h1>CodeMirror: XQuery mode</h1>
44
45 <div class="cm-s-default">
46 <textarea id="code" name="code">
36 .CodeMirror {
37 border-top: 1px solid black; border-bottom: 1px solid black;
38 height:400px;
39 }
40 </style>
41 </head>
42 <body>
43 <h1>CodeMirror: XQuery mode</h1>
44
45 <div class="cm-s-default">
46 <textarea id="code" name="code">
47 47 xquery version &quot;1.0-ml&quot;;
48 48 (: this is
49 : a
49 : a
50 50 "comment" :)
51 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 52 let $joe:=1
53 53 return element element {
54 attribute attribute { 1 },
55 element test { &#39;a&#39; },
56 attribute foo { &quot;bar&quot; },
57 fn:doc()[ foo/@bar eq $let ],
58 //x }
59
54 attribute attribute { 1 },
55 element test { &#39;a&#39; },
56 attribute foo { &quot;bar&quot; },
57 fn:doc()[ foo/@bar eq $let ],
58 //x }
59
60 60 (: a more 'evil' test :)
61 61 (: Modified Blakeley example (: with nested comment :) ... :)
62 62 declare private function local:declare() {()};
63 63 declare private function local:private() {()};
64 64 declare private function local:function() {()};
65 65 declare private function local:local() {()};
66 66 let $let := &lt;let&gt;let $let := &quot;let&quot;&lt;/let&gt;
67 67 return element element {
68 attribute attribute { try { xdmp:version() } catch($e) { xdmp:log($e) } },
69 attribute fn:doc { &quot;bar&quot; castable as xs:string },
70 element text { text { &quot;text&quot; } },
71 fn:doc()[ child::eq/(@bar | attribute::attribute) eq $let ],
72 //fn:doc
68 attribute attribute { try { xdmp:version() } catch($e) { xdmp:log($e) } },
69 attribute fn:doc { &quot;bar&quot; castable as xs:string },
70 element text { text { &quot;text&quot; } },
71 fn:doc()[ child::eq/(@bar | attribute::attribute) eq $let ],
72 //fn:doc
73 73 }
74 74
75 75
76 76
77 77 xquery version &quot;1.0-ml&quot;;
78 78
79 79 (: Copyright 2006-2010 Mark Logic Corporation. :)
80 80
81 81 (:
82 82 : Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
83 83 : you may not use this file except in compliance with the License.
84 84 : You may obtain a copy of the License at
85 85 :
86 86 : http://www.apache.org/licenses/LICENSE-2.0
87 87 :
88 88 : Unless required by applicable law or agreed to in writing, software
89 89 : distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
90 90 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
91 91 : See the License for the specific language governing permissions and
92 92 : limitations under the License.
93 93 :)
94 94
95 95 module namespace json = &quot;http://marklogic.com/json&quot;;
96 96 declare default function namespace &quot;http://www.w3.org/2005/xpath-functions&quot;;
97 97
98 98 (: Need to backslash escape any double quotes, backslashes, and newlines :)
99 99 declare function json:escape($s as xs:string) as xs:string {
100 100 let $s := replace($s, &quot;\\&quot;, &quot;\\\\&quot;)
101 101 let $s := replace($s, &quot;&quot;&quot;&quot;, &quot;\\&quot;&quot;&quot;)
102 102 let $s := replace($s, codepoints-to-string((13, 10)), &quot;\\n&quot;)
103 103 let $s := replace($s, codepoints-to-string(13), &quot;\\n&quot;)
104 104 let $s := replace($s, codepoints-to-string(10), &quot;\\n&quot;)
105 105 return $s
106 106 };
107 107
108 108 declare function json:atomize($x as element()) as xs:string {
109 109 if (count($x/node()) = 0) then 'null'
110 110 else if ($x/@type = &quot;number&quot;) then
111 111 let $castable := $x castable as xs:float or
112 112 $x castable as xs:double or
113 113 $x castable as xs:decimal
114 114 return
115 115 if ($castable) then xs:string($x)
116 116 else error(concat(&quot;Not a number: &quot;, xdmp:describe($x)))
117 117 else if ($x/@type = &quot;boolean&quot;) then
118 118 let $castable := $x castable as xs:boolean
119 119 return
120 120 if ($castable) then xs:string(xs:boolean($x))
121 121 else error(concat(&quot;Not a boolean: &quot;, xdmp:describe($x)))
122 122 else concat('&quot;', json:escape($x), '&quot;')
123 123 };
124 124
125 125 (: Print the thing that comes after the colon :)
126 126 declare function json:print-value($x as element()) as xs:string {
127 127 if (count($x/*) = 0) then
128 128 json:atomize($x)
129 129 else if ($x/@quote = &quot;true&quot;) then
130 130 concat('&quot;', json:escape(xdmp:quote($x/node())), '&quot;')
131 131 else
132 132 string-join(('{',
133 133 string-join(for $i in $x/* return json:print-name-value($i), &quot;,&quot;),
134 134 '}'), &quot;&quot;)
135 135 };
136 136
137 137 (: Print the name and value both :)
138 138 declare function json:print-name-value($x as element()) as xs:string? {
139 139 let $name := name($x)
140 140 let $first-in-array :=
141 141 count($x/preceding-sibling::*[name(.) = $name]) = 0 and
142 142 (count($x/following-sibling::*[name(.) = $name]) &gt; 0 or $x/@array = &quot;true&quot;)
143 143 let $later-in-array := count($x/preceding-sibling::*[name(.) = $name]) &gt; 0
144 144 return
145 145
146 146 if ($later-in-array) then
147 147 () (: I was handled previously :)
148 148 else if ($first-in-array) then
149 149 string-join(('&quot;', json:escape($name), '&quot;:[',
150 150 string-join((for $i in ($x, $x/following-sibling::*[name(.) = $name]) return json:print-value($i)), &quot;,&quot;),
151 151 ']'), &quot;&quot;)
152 152 else
153 153 string-join(('&quot;', json:escape($name), '&quot;:', json:print-value($x)), &quot;&quot;)
154 154 };
155 155
156 156 (:~
157 157 Transforms an XML element into a JSON string representation. See http://json.org.
158 158 &lt;p/&gt;
159 159 Sample usage:
160 160 &lt;pre&gt;
161 161 xquery version &quot;1.0-ml&quot;;
162 162 import module namespace json=&quot;http://marklogic.com/json&quot; at &quot;json.xqy&quot;;
163 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 164 &lt;/pre&gt;
165 165 Sample transformations:
166 166 &lt;pre&gt;
167 167 &amp;lt;e/&amp;gt; becomes {&quot;e&quot;:null}
168 168 &amp;lt;e&amp;gt;text&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:&quot;text&quot;}
169 169 &amp;lt;e&amp;gt;quote &quot; escaping&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:&quot;quote \&quot; escaping&quot;}
170 170 &amp;lt;e&amp;gt;backslash \ escaping&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:&quot;backslash \\ escaping&quot;}
171 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 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 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 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 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 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 177 &lt;/pre&gt;
178 178 &lt;p/&gt;
179 179 Namespace URIs are ignored. Namespace prefixes are included in the JSON name.
180 180 &lt;p/&gt;
181 181 Attributes are ignored, except for the special attribute @array=&quot;true&quot; that
182 182 indicates the JSON serialization should write the node, even if single, as an
183 183 array, and the attribute @type that can be set to &quot;boolean&quot; or &quot;number&quot; to
184 184 dictate the value should be written as that type (unquoted). There's also
185 185 an @quote attribute that when set to true writes the inner content as text
186 186 rather than as structured JSON, useful for sending some XHTML over the
187 187 wire.
188 188 &lt;p/&gt;
189 189 Text nodes within mixed content are ignored.
190 190
191 191 @param $x Element node to convert
192 192 @return String holding JSON serialized representation of $x
193 193
194 194 @author Jason Hunter
195 195 @version 1.0.1
196
196
197 197 Ported to xquery 1.0-ml; double escaped backslashes in json:escape
198 198 :)
199 199 declare function json:serialize($x as element()) as xs:string {
200 200 string-join(('{', json:print-name-value($x), '}'), &quot;&quot;)
201 201 };
202 </textarea>
203 </div>
204
205 <script>
202 </textarea>
203 </div>
204
205 <script>
206 206 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
207 207 lineNumbers: true,
208 208 matchBrackets: true,
209 209 theme: "xq-dark"
210 210 });
211 </script>
212
213 <p><strong>MIME types defined:</strong> <code>application/xquery</code>.</p>
214
215 <p>Development of the CodeMirror XQuery mode was sponsored by
216 <a href="http://marklogic.com">MarkLogic</a> and developed by
211 </script>
212
213 <p><strong>MIME types defined:</strong> <code>application/xquery</code>.</p>
214
215 <p>Development of the CodeMirror XQuery mode was sponsored by
216 <a href="http://marklogic.com">MarkLogic</a> and developed by
217 217 <a href="https://twitter.com/mbrevoort">Mike Brevoort</a>.
218 218 </p>
219
220 </body>
219
220 </body>
221 221 </html>
General Comments 0
You need to be logged in to leave comments. Login now