';
193 | for (var k in data) {
194 | if (data[k] instanceof Object) {
195 | html = html + '
' + k + ' ' + HyperVisor.viewMetaRecursive(data[k]);
196 | } else {
197 | html = html + '
' + k + ' ' + ('' + data[k]).escapeHTML() + '';
198 | }
199 | html = html + '
';
200 | }
201 | html = html + '
';
202 | return html;
203 | },
204 |
205 | //
206 | viewMeta: function(){
207 | $.getJSON('doc.json', function(data) {
208 | $('.box').hide();
209 | $('#raw').show();
210 | $('#raw').append(HyperVisor.viewMetaRecursive(data));
211 | });
212 | },
213 |
214 | //
215 | clickABCTab: function(letter) {
216 | $("input#search-letter").val(letter).trigger('keyup');
217 | },
218 |
219 | //
220 | getUrlVars: function() {
221 | var vars = [], hash;
222 | var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
223 | for(var i = 0; i < hashes.length; i++)
224 | {
225 | hash = hashes[i].split('=');
226 | vars.push(hash[0]);
227 | vars[hash[0]] = hash[1];
228 | }
229 | return vars;
230 | },
231 |
232 | };
233 |
234 |
235 |
236 | /*
237 | function sortObj(arr){
238 | // Setup Arrays
239 | var sortedKeys = new Array();
240 | var sortedObj = {};
241 | // Separate keys and sort them
242 | for (var i in arr){
243 | sortedKeys.push(i);
244 | }
245 | sortedKeys.sort();
246 | // Reconstruct sorted obj based on keys
247 | for (var i in sortedKeys){
248 | sortedObj[sortedKeys[i]] = arr[sortedKeys[i]];
249 | }
250 | return sortedObj;
251 | };
252 | */
253 |
254 |
--------------------------------------------------------------------------------
/assets/stylesheets/normalize.css:
--------------------------------------------------------------------------------
1 | /*! normalize.css 2011-08-31T22:02 UTC · http://github.com/necolas/normalize.css */
2 |
3 | /* =============================================================================
4 | HTML5 display definitions
5 | ========================================================================== */
6 |
7 | /*
8 | * Corrects block display not defined in IE6/7/8/9 & FF3
9 | */
10 |
11 | article,
12 | aside,
13 | details,
14 | figcaption,
15 | figure,
16 | footer,
17 | header,
18 | hgroup,
19 | nav,
20 | section {
21 | display: block;
22 | }
23 |
24 | /*
25 | * Corrects inline-block display not defined in IE6/7/8/9 & FF3
26 | */
27 |
28 | audio,
29 | canvas,
30 | video {
31 | display: inline-block;
32 | *display: inline;
33 | *zoom: 1;
34 | }
35 |
36 | /*
37 | * Prevents modern browsers from displaying 'audio' without controls
38 | */
39 |
40 | audio:not([controls]) {
41 | display: none;
42 | }
43 |
44 | /*
45 | * Addresses styling for 'hidden' attribute not present in IE7/8/9, FF3, S4
46 | * Known issue: no IE6 support
47 | */
48 |
49 | [hidden] {
50 | display: none;
51 | }
52 |
53 |
54 | /* =============================================================================
55 | Base
56 | ========================================================================== */
57 |
58 | /*
59 | * 1. Corrects text resizing oddly in IE6/7 when body font-size is set using em units
60 | * http://clagnut.com/blog/348/#c790
61 | * 2. Keeps page centred in all browsers regardless of content height
62 | * 3. Prevents iOS text size adjust after orientation change, without disabling user zoom
63 | * www.456bereastreet.com/archive/201012/controlling_text_size_in_safari_for_ios_without_disabling_user_zoom/
64 | */
65 |
66 | html {
67 | font-size: 100%; /* 1 */
68 | overflow-y: scroll; /* 2 */
69 | -webkit-text-size-adjust: 100%; /* 3 */
70 | -ms-text-size-adjust: 100%; /* 3 */
71 | }
72 |
73 | /*
74 | * Addresses margins handled incorrectly in IE6/7
75 | */
76 |
77 | body {
78 | margin: 0;
79 | }
80 |
81 | /*
82 | * Addresses font-family inconsistency between 'textarea' and other form elements.
83 | */
84 |
85 | body,
86 | button,
87 | input,
88 | select,
89 | textarea {
90 | font-family: sans-serif;
91 | }
92 |
93 |
94 | /* =============================================================================
95 | Links
96 | ========================================================================== */
97 |
98 | a {
99 | color: #00e;
100 | }
101 |
102 | a:visited {
103 | color: #551a8b;
104 | }
105 |
106 | /*
107 | * Addresses outline displayed oddly in Chrome
108 | */
109 |
110 | a:focus {
111 | outline: thin dotted;
112 | }
113 |
114 | /*
115 | * Improves readability when focused and also mouse hovered in all browsers
116 | * people.opera.com/patrickl/experiments/keyboard/test
117 | */
118 |
119 | a:hover,
120 | a:active {
121 | outline: 0;
122 | }
123 |
124 |
125 | /* =============================================================================
126 | Typography
127 | ========================================================================== */
128 |
129 | /*
130 | * Addresses styling not present in IE7/8/9, S5, Chrome
131 | */
132 |
133 | abbr[title] {
134 | border-bottom: 1px dotted;
135 | }
136 |
137 | /*
138 | * Addresses style set to 'bolder' in FF3/4, S4/5, Chrome
139 | */
140 |
141 | b,
142 | strong {
143 | font-weight: bold;
144 | }
145 |
146 | blockquote {
147 | margin: 1em 40px;
148 | }
149 |
150 | /*
151 | * Addresses styling not present in S5, Chrome
152 | */
153 |
154 | dfn {
155 | font-style: italic;
156 | }
157 |
158 | /*
159 | * Addresses styling not present in IE6/7/8/9
160 | */
161 |
162 | mark {
163 | background: #ff0;
164 | color: #000;
165 | }
166 |
167 | /*
168 | * Corrects font family set oddly in IE6, S4/5, Chrome
169 | * en.wikipedia.org/wiki/User:Davidgothberg/Test59
170 | */
171 |
172 | pre,
173 | code,
174 | kbd,
175 | samp {
176 | font-family: monospace, serif;
177 | _font-family: 'courier new', monospace;
178 | font-size: 1em;
179 | }
180 |
181 | /*
182 | * Improves readability of pre-formatted text in all browsers
183 | */
184 |
185 | pre {
186 | white-space: pre;
187 | white-space: pre-wrap;
188 | word-wrap: break-word;
189 | }
190 |
191 | /*
192 | * 1. Addresses CSS quotes not supported in IE6/7
193 | * 2. Addresses quote property not supported in S4
194 | */
195 |
196 | /* 1 */
197 |
198 | q {
199 | quotes: none;
200 | }
201 |
202 | /* 2 */
203 |
204 | q:before,
205 | q:after {
206 | content: '';
207 | content: none;
208 | }
209 |
210 | small {
211 | font-size: 75%;
212 | }
213 |
214 | /*
215 | * Prevents sub and sup affecting line-height in all browsers
216 | * gist.github.com/413930
217 | */
218 |
219 | sub,
220 | sup {
221 | font-size: 75%;
222 | line-height: 0;
223 | position: relative;
224 | vertical-align: baseline;
225 | }
226 |
227 | sup {
228 | top: -0.5em;
229 | }
230 |
231 | sub {
232 | bottom: -0.25em;
233 | }
234 |
235 |
236 | /* =============================================================================
237 | Lists
238 | ========================================================================== */
239 |
240 | ul,
241 | ol {
242 | margin: 1em 0;
243 | padding: 0 0 0 40px;
244 | }
245 |
246 | dd {
247 | margin: 0 0 0 40px;
248 | }
249 |
250 | nav ul,
251 | nav ol {
252 | list-style: none;
253 | list-style-image: none;
254 | }
255 |
256 |
257 | /* =============================================================================
258 | Embedded content
259 | ========================================================================== */
260 |
261 | /*
262 | * 1. Removes border when inside 'a' element in IE6/7/8/9, F3
263 | * 2. Improves image quality when scaled in IE7
264 | * code.flickr.com/blog/2008/11/12/on-ui-quality-the-little-things-client-side-image-resizing/
265 | */
266 |
267 | img {
268 | border: 0; /* 1 */
269 | -ms-interpolation-mode: bicubic; /* 2 */
270 | }
271 |
272 | /*
273 | * Corrects overflow displayed oddly in IE9
274 | */
275 |
276 | svg:not(:root) {
277 | overflow: hidden;
278 | }
279 |
280 |
281 | /* =============================================================================
282 | Figures
283 | ========================================================================== */
284 |
285 | /*
286 | * Addresses margin not present in IE6/7/8/9, S5, O11
287 | */
288 |
289 | figure {
290 | margin: 0;
291 | }
292 |
293 |
294 | /* =============================================================================
295 | Forms
296 | ========================================================================== */
297 |
298 | /*
299 | * Corrects margin displayed oddly in IE6/7
300 | */
301 |
302 | form {
303 | margin: 0;
304 | }
305 |
306 | /*
307 | * Define consistent margin and padding
308 | */
309 |
310 | fieldset {
311 | margin: 0 2px;
312 | padding: 0.35em 0.625em 0.75em;
313 | }
314 |
315 | /*
316 | * 1. Corrects color not being inherited in IE6/7/8/9
317 | * 2. Corrects alignment displayed oddly in IE6/7
318 | */
319 |
320 | legend {
321 | border: 0; /* 1 */
322 | *margin-left: -7px; /* 2 */
323 | }
324 |
325 | /*
326 | * 1. Corrects font size not being inherited in all browsers
327 | * 2. Addresses margins set differently in IE6/7, F3/4, S5, Chrome
328 | * 3. Improves appearance and consistency in all browsers
329 | */
330 |
331 | button,
332 | input,
333 | select,
334 | textarea {
335 | font-size: 100%; /* 1 */
336 | margin: 0; /* 2 */
337 | vertical-align: baseline; /* 3 */
338 | *vertical-align: middle; /* 3 */
339 | }
340 |
341 | /*
342 | * 1. Addresses FF3/4 setting line-height using !important in the UA stylesheet
343 | * 2. Corrects inner spacing displayed oddly in IE6/7
344 | */
345 |
346 | button,
347 | input {
348 | line-height: normal; /* 1 */
349 | *overflow: visible; /* 2 */
350 | }
351 |
352 | /*
353 | * Corrects overlap and whitespace issue for buttons and inputs in IE6/7
354 | * Known issue: reintroduces inner spacing
355 | */
356 |
357 | table button,
358 | table input {
359 | *overflow: auto;
360 | }
361 |
362 | /*
363 | * 1. Improves usability and consistency of cursor style between image-type 'input' and others
364 | * 2. Corrects inability to style clickable 'input' types in iOS
365 | */
366 |
367 | button,
368 | html input[type="button"],
369 | input[type="reset"],
370 | input[type="submit"] {
371 | cursor: pointer; /* 1 */
372 | -webkit-appearance: button; /* 2 */
373 | }
374 |
375 | /*
376 | * 1. Addresses box sizing set to content-box in IE8/9
377 | * 2. Addresses excess padding in IE8/9
378 | */
379 |
380 | input[type="checkbox"],
381 | input[type="radio"] {
382 | box-sizing: border-box; /* 1 */
383 | padding: 0; /* 2 */
384 | }
385 |
386 | /*
387 | * 1. Addresses appearance set to searchfield in S5, Chrome
388 | * 2. Addresses box sizing set to border-box in S5, Chrome (include -moz to future-proof)
389 | */
390 |
391 | input[type="search"] {
392 | -webkit-appearance: textfield; /* 1 */
393 | -moz-box-sizing: content-box;
394 | -webkit-box-sizing: content-box; /* 2 */
395 | box-sizing: content-box;
396 | }
397 |
398 | /*
399 | * Corrects inner padding displayed oddly in S5, Chrome on OSX
400 | */
401 |
402 | input[type="search"]::-webkit-search-decoration {
403 | -webkit-appearance: none;
404 | }
405 |
406 | /*
407 | * Corrects inner padding and border displayed oddly in FF3/4
408 | * www.sitepen.com/blog/2008/05/14/the-devils-in-the-details-fixing-dojos-toolbar-buttons/
409 | */
410 |
411 | button::-moz-focus-inner,
412 | input::-moz-focus-inner {
413 | border: 0;
414 | padding: 0;
415 | }
416 |
417 | /*
418 | * 1. Removes default vertical scrollbar in IE6/7/8/9
419 | * 2. Improves readability and alignment in all browsers
420 | */
421 |
422 | textarea {
423 | overflow: auto; /* 1 */
424 | vertical-align: top; /* 2 */
425 | }
426 |
427 |
428 | /* =============================================================================
429 | Tables
430 | ========================================================================== */
431 |
432 | /*
433 | * Remove most spacing between table cells
434 | */
435 |
436 | table {
437 | border-collapse: collapse;
438 | border-spacing: 0;
439 | }
440 |
--------------------------------------------------------------------------------
/COPYING.rdoc:
--------------------------------------------------------------------------------
1 | = COPYRIGHT NOTICES
2 |
3 | == Hypervisor
4 |
5 | Copyright:: (c) 2011 Thomas Sawyer
6 | License:: BSD-2-Clause
7 | Website:: http://github.com/rubyworks/hypervisor
8 |
9 | Copyright 2011 Thomas Sawyer. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | 1. Redistributions of source code must retain the above copyright notice,
15 | this list of conditions and the following disclaimer.
16 |
17 | 2. Redistributions in binary form must reproduce the above copyright
18 | notice, this list of conditions and the following disclaimer in the
19 | documentation and/or other materials provided with the distribution.
20 |
21 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
23 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
28 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 |
32 |
33 | == jQuery
34 |
35 | Copyright:: (c) 2011 John Resig, http://jquery.com/
36 | License:: MIT
37 | Website:: http://jquery.com
38 |
39 | Copyright (c) 2011 John Resig, http://jquery.com/
40 |
41 | Permission is hereby granted, free of charge, to any person obtaining
42 | a copy of this software and associated documentation files (the
43 | "Software"), to deal in the Software without restriction, including
44 | without limitation the rights to use, copy, modify, merge, publish,
45 | distribute, sublicense, and/or sell copies of the Software, and to
46 | permit persons to whom the Software is furnished to do so, subject to
47 | the following conditions:
48 |
49 | The above copyright notice and this permission notice shall be
50 | included in all copies or substantial portions of the Software.
51 |
52 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
53 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
54 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
55 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
56 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
57 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
58 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
59 |
60 |
61 | == Highlight.js
62 |
63 | Copyright:: (c) 2006 Ivan Sagalaev
64 | License:: BSD-3-Caluse
65 | Website:: http://softwaremaniacs.org/soft/highlight/en/
66 |
67 | Copyright (c) 2006, Ivan Sagalaev
68 | All rights reserved.
69 |
70 | Redistribution and use in source and binary forms, with or without
71 | modification, are permitted provided that the following conditions are met:
72 |
73 | * Redistributions of source code must retain the above copyright
74 | notice, this list of conditions and the following disclaimer.
75 |
76 | * Redistributions in binary form must reproduce the above copyright
77 | notice, this list of conditions and the following disclaimer in the
78 | documentation and/or other materials provided with the distribution.
79 |
80 | * Neither the name of highlight.js nor the names of its contributors
81 | may be used to endorse or promote products derived from this software
82 | without specific prior written permission.
83 |
84 | THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
85 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
86 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
87 | DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
88 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
89 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
90 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
91 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
92 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
93 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
94 |
95 | (http://spdx.org/licenses/BSD-3-Clause)
96 |
97 |
98 | == Showdown
99 |
100 | Copyright:: (c) 2007 John Fraser.
101 | License:: BSD-3-Clause
102 | Website:: http://www.attacklab.net/
103 |
104 | Copyright (c) 2007, John Fraser
105 |
106 | All rights reserved.
107 |
108 | Original Markdown copyright (c) 2004, John Gruber
109 |
110 | All rights reserved.
111 |
112 | Redistribution and use in source and binary forms, with or without
113 | modification, are permitted provided that the following conditions are
114 | met:
115 |
116 | * Redistributions of source code must retain the above copyright notice,
117 | this list of conditions and the following disclaimer.
118 |
119 | * Redistributions in binary form must reproduce the above copyright
120 | notice, this list of conditions and the following disclaimer in the
121 | documentation and/or other materials provided with the distribution.
122 |
123 | * Neither the name "Markdown" nor the names of its contributors may
124 | be used to endorse or promote products derived from this software
125 | without specific prior written permission.
126 |
127 | This software is provided by the copyright holders and contributors "as
128 | is" and any express or implied warranties, including, but not limited
129 | to, the implied warranties of merchantability and fitness for a
130 | particular purpose are disclaimed. In no event shall the copyright owner
131 | or contributors be liable for any direct, indirect, incidental, special,
132 | exemplary, or consequential damages (including, but not limited to,
133 | procurement of substitute goods or services; loss of use, data, or
134 | profits; or business interruption) however caused and on any theory of
135 | liability, whether in contract, strict liability, or tort (including
136 | negligence or otherwise) arising in any way out of the use of this
137 | software, even if advised of the possibility of such damage.
138 |
139 |
140 | == Quicksearch
141 |
142 | Copyright:: (c) Rik Lomas
143 | License:: MIT
144 | Website:: http://github.com/riklomas/quicksearch
145 |
146 | Permission is hereby granted, free of charge, to any person obtaining
147 | a copy of this software and associated documentation files (the
148 | "Software"), to deal in the Software without restriction, including
149 | without limitation the rights to use, copy, modify, merge, publish,
150 | distribute, sublicense, and/or sell copies of the Software, and to
151 | permit persons to whom the Software is furnished to do so, subject to
152 | the following conditions:
153 |
154 | The above copyright notice and this permission notice shall be
155 | included in all copies or substantial portions of the Software.
156 |
157 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
158 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
159 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
160 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
161 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
162 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
163 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
164 |
165 |
166 | == Keymaster
167 |
168 | Copyright:: (c) 2011 Thomas Fuchs
169 | License:: MIT
170 | Website:: https://github.com/madrobby/keymaster
171 |
172 | Copyright (c) 2011 Thomas Fuchs
173 |
174 | Permission is hereby granted, free of charge, to any person obtaining
175 | a copy of this software and associated documentation files (the
176 | "Software"), to deal in the Software without restriction, including
177 | without limitation the rights to use, copy, modify, merge, publish,
178 | distribute, sublicense, and/or sell copies of the Software, and to
179 | permit persons to whom the Software is furnished to do so, subject to
180 | the following conditions:
181 |
182 | The above copyright notice and this permission notice shall be
183 | included in all copies or substantial portions of the Software.
184 |
185 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
186 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
187 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
188 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
189 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
190 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
191 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
192 |
193 |
194 | == jQuery Mouse Wheel
195 |
196 | Copyright:: (c) 2010 Brandon Aaron
197 | License:: MIT
198 | Website:: http://brandonaaron.net/
199 |
200 | Copyright 2010, Brandon Aaron (http://brandonaaron.net/)
201 |
202 | Permission is hereby granted, free of charge, to any person obtaining
203 | a copy of this software and associated documentation files (the
204 | "Software"), to deal in the Software without restriction, including
205 | without limitation the rights to use, copy, modify, merge, publish,
206 | distribute, sublicense, and/or sell copies of the Software, and to
207 | permit persons to whom the Software is furnished to do so, subject to
208 | the following conditions:
209 |
210 | The above copyright notice and this permission notice shall be
211 | included in all copies or substantial portions of the Software.
212 |
213 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
214 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
215 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
216 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
217 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
218 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
219 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
220 |
--------------------------------------------------------------------------------
/assets/javascripts/showdown.js:
--------------------------------------------------------------------------------
1 | //
2 | // showdown.js -- A javascript port of Markdown.
3 | //
4 | // Copyright (c) 2007 John Fraser.
5 | //
6 | // Original Markdown Copyright (c) 2004-2005 John Gruber
7 | //
8 | //
9 | // The full source distribution is at:
10 | //
11 | // A A L
12 | // T C A
13 | // T K B
14 | //
15 | //
16 | //
17 |
18 | //
19 | // Wherever possible, Showdown is a straight, line-by-line port
20 | // of the Perl version of Markdown.
21 | //
22 | // This is not a normal parser design; it's basically just a
23 | // series of string substitutions. It's hard to read and
24 | // maintain this way, but keeping Showdown close to the original
25 | // design makes it easier to port new features.
26 | //
27 | // More importantly, Showdown behaves like markdown.pl in most
28 | // edge cases. So web applications can do client-side preview
29 | // in Javascript, and then build identical HTML on the server.
30 | //
31 | // This port needs the new RegExp functionality of ECMA 262,
32 | // 3rd Edition (i.e. Javascript 1.5). Most modern web browsers
33 | // should do fine. Even with the new regular expression features,
34 | // We do a lot of work to emulate Perl's regex functionality.
35 | // The tricky changes in this file mostly have the "attacklab:"
36 | // label. Major or self-explanatory changes don't.
37 | //
38 | // Smart diff tools like Araxis Merge will be able to match up
39 | // this file with markdown.pl in a useful way. A little tweaking
40 | // helps: in a copy of markdown.pl, replace "#" with "//" and
41 | // replace "$text" with "text". Be sure to ignore whitespace
42 | // and line endings.
43 | //
44 |
45 |
46 | //
47 | // Showdown usage:
48 | //
49 | // var text = "Markdown *rocks*.";
50 | //
51 | // var converter = new Attacklab.showdown.converter();
52 | // var html = converter.makeHtml(text);
53 | //
54 | // alert(html);
55 | //
56 | // Note: move the sample code to the bottom of this
57 | // file before uncommenting it.
58 | //
59 |
60 |
61 | //
62 | // Attacklab namespace
63 | //
64 | var Attacklab = Attacklab || {}
65 |
66 | //
67 | // Showdown namespace
68 | //
69 | Attacklab.showdown = Attacklab.showdown || {}
70 |
71 | //
72 | // converter
73 | //
74 | // Wraps all "globals" so that the only thing
75 | // exposed is makeHtml().
76 | //
77 | Attacklab.showdown.converter = function() {
78 |
79 |
80 | // g_urls and g_titles allow arbitrary user-entered strings as keys. This
81 | // caused an exception (and hence stopped the rendering) when the user entered
82 | // e.g. [push] or [__proto__]. Adding a prefix to the actual key prevents this
83 | // (since no builtin property starts with "s_"). See
84 | // http://meta.stackoverflow.com/questions/64655/strange-wmd-bug
85 | // (granted, switching from Array() to Object() alone would have left only __proto__
86 | // to be a problem)
87 | var SaveHash = function () {
88 | this.set = function (key, value) {
89 | this["s_" + key] = value;
90 | }
91 | this.get = function (key) {
92 | return this["s_" + key];
93 | }
94 | }
95 |
96 | //
97 | // Globals:
98 | //
99 |
100 | // Global hashes, used by various utility routines
101 | var g_urls;
102 | var g_titles;
103 | var g_html_blocks;
104 |
105 | // Used to track when we're inside an ordered or unordered list
106 | // (see _ProcessListItems() for details):
107 | var g_list_level = 0;
108 |
109 |
110 | this.makeHtml = function(text) {
111 | //
112 | // Main function. The order in which other subs are called here is
113 | // essential. Link and image substitutions need to happen before
114 | // _EscapeSpecialCharsWithinTagAttributes(), so that any *'s or _'s in the
115 | // and tags get encoded.
116 | //
117 |
118 | // Clear the global hashes. If we don't clear these, you get conflicts
119 | // from other articles when generating a page which contains more than
120 | // one article (e.g. an index page that shows the N most recent
121 | // articles):
122 | g_urls = new SaveHash();
123 | g_titles = new SaveHash();
124 | g_html_blocks = new Array();
125 |
126 | // attacklab: Replace ~ with ~T
127 | // This lets us use tilde as an escape char to avoid md5 hashes
128 | // The choice of character is arbitray; anything that isn't
129 | // magic in Markdown will work.
130 | text = text.replace(/~/g,"~T");
131 |
132 | // attacklab: Replace $ with ~D
133 | // RegExp interprets $ as a special character
134 | // when it's in a replacement string
135 | text = text.replace(/\$/g,"~D");
136 |
137 | // Standardize line endings
138 | text = text.replace(/\r\n/g,"\n"); // DOS to Unix
139 | text = text.replace(/\r/g,"\n"); // Mac to Unix
140 |
141 | // Make sure text begins and ends with a couple of newlines:
142 | text = "\n\n" + text + "\n\n";
143 |
144 | // Convert all tabs to spaces.
145 | text = _Detab(text);
146 |
147 | // Strip any lines consisting only of spaces and tabs.
148 | // This makes subsequent regexen easier to write, because we can
149 | // match consecutive blank lines with /\n+/ instead of something
150 | // contorted like /[ \t]*\n+/ .
151 | text = text.replace(/^[ \t]+$/mg,"");
152 |
153 | // Turn block-level HTML blocks into hash entries
154 | text = _HashHTMLBlocks(text);
155 |
156 | // Strip link definitions, store in hashes.
157 | text = _StripLinkDefinitions(text);
158 |
159 | text = _RunBlockGamut(text);
160 |
161 | text = _UnescapeSpecialChars(text);
162 |
163 | // attacklab: Restore dollar signs
164 | text = text.replace(/~D/g,"$$");
165 |
166 | // attacklab: Restore tildes
167 | text = text.replace(/~T/g,"~");
168 |
169 | return text;
170 | }
171 |
172 | var _StripLinkDefinitions = function(text) {
173 | //
174 | // Strips link definitions from text, stores the URLs and titles in
175 | // hash references.
176 | //
177 |
178 | // Link defs are in the form: ^[id]: url "optional title"
179 |
180 | /*
181 | var text = text.replace(/
182 | ^[ ]{0,3}\[(.+)\]: // id = $1 attacklab: g_tab_width - 1
183 | [ \t]*
184 | \n? // maybe *one* newline
185 | [ \t]*
186 | (\S+?)>? // url = $2
187 | [ \t]*
188 | \n? // maybe one newline
189 | [ \t]*
190 | (?:
191 | (\n*) // any lines skipped = $3 attacklab: lookbehind removed
192 | ["(]
193 | (.+?) // title = $4
194 | [")]
195 | [ \t]*
196 | )? // title is optional
197 | (?:\n+|$)
198 | /gm,
199 | function(){...});
200 | */
201 | var text = text.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*(\S+?)>?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+)/gm,
202 | function (wholeMatch,m1,m2,m3,m4) {
203 | m1 = m1.toLowerCase();
204 | g_urls.set(m1, _EncodeAmpsAndAngles(m2)); // Link IDs are case-insensitive
205 | if (m3) {
206 | // Oops, found blank lines, so it's not a title.
207 | // Put back the parenthetical statement we stole.
208 | return m3+m4;
209 | } else if (m4) {
210 | g_titles.set(m1, m4.replace(/"/g,"""));
211 | }
212 |
213 | // Completely remove the definition from the text
214 | return "";
215 | }
216 | );
217 |
218 | return text;
219 | }
220 |
221 | var _HashHTMLBlocks = function(text) {
222 | // attacklab: Double up blank lines to reduce lookaround
223 | text = text.replace(/\n/g,"\n\n");
224 |
225 | // Hashify HTML blocks:
226 | // We only want to do this for block-level HTML tags, such as headers,
227 | // lists, and tables. That's because we still want to wrap
");});
685 |
686 | // atx-style headers:
687 | // # Header 1
688 | // ## Header 2
689 | // ## Header 2 with closing hashes ##
690 | // ...
691 | // ###### Header 6
692 | //
693 |
694 | /*
695 | text = text.replace(/
696 | ^(\#{1,6}) // $1 = string of #'s
697 | [ \t]*
698 | (.+?) // $2 = Header text
699 | [ \t]*
700 | \#* // optional closing #'s (not counted)
701 | \n+
702 | /gm, function() {...});
703 | */
704 |
705 | text = text.replace(/^([#=]{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,
706 | function(wholeMatch,m1,m2) {
707 | var h_level = m1.length;
708 | return hashBlock("" + _RunSpanGamut(m2) + "");
709 | });
710 |
711 | return text;
712 | }
713 |
714 | // This declaration keeps Dojo compressor from outputting garbage:
715 | var _ProcessListItems;
716 |
717 | var _DoLists = function(text) {
718 | //
719 | // Form HTML ordered (numbered) and unordered (bulleted) lists.
720 | //
721 |
722 | // attacklab: add sentinel to hack around khtml/safari bug:
723 | // http://bugs.webkit.org/show_bug.cgi?id=11231
724 | text += "~0";
725 |
726 | // Re-usable pattern to match any entirel ul or ol list:
727 |
728 | /*
729 | var whole_list = /
730 | ( // $1 = whole list
731 | ( // $2
732 | [ ]{0,3} // attacklab: g_tab_width - 1
733 | ([*+-]|\d+[.]) // $3 = first list item marker
734 | [ \t]+
735 | )
736 | [^\r]+?
737 | ( // $4
738 | ~0 // sentinel for workaround; should be $
739 | |
740 | \n{2,}
741 | (?=\S)
742 | (?! // Negative lookahead for another list item marker
743 | [ \t]*
744 | (?:[*+-]|\d+[.])[ \t]+
745 | )
746 | )
747 | )/g
748 | */
749 | var whole_list = /^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;
750 |
751 | if (g_list_level) {
752 | text = text.replace(whole_list,function(wholeMatch,m1,m2) {
753 | var list = m1;
754 | var list_type = (m2.search(/[*+-]/g)>-1) ? "ul" : "ol";
755 |
756 | // Turn double returns into triple returns, so that we can make a
757 | // paragraph for the last item in a list, if necessary:
758 | list = list.replace(/\n{2,}/g,"\n\n\n");;
759 | var result = _ProcessListItems(list);
760 |
761 | // Trim any trailing whitespace, to put the closing `$list_type>`
762 | // up on the preceding line, to get it past the current stupid
763 | // HTML block parser. This is a hack to work around the terrible
764 | // hack that is the HTML block parser.
765 | result = result.replace(/\s+$/,"");
766 | result = "<"+list_type+">" + result + ""+list_type+">\n";
767 | return result;
768 | });
769 | } else {
770 | whole_list = /(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g;
771 | text = text.replace(whole_list,function(wholeMatch,m1,m2,m3) {
772 | var runup = m1;
773 | var list = m2;
774 |
775 | var list_type = (m3.search(/[*+-]/g)>-1) ? "ul" : "ol";
776 | // Turn double returns into triple returns, so that we can make a
777 | // paragraph for the last item in a list, if necessary:
778 | var list = list.replace(/\n{2,}/g,"\n\n\n");;
779 | var result = _ProcessListItems(list);
780 | result = runup + "<"+list_type+">\n" + result + ""+list_type+">\n";
781 | return result;
782 | });
783 | }
784 |
785 | // attacklab: strip sentinel
786 | text = text.replace(/~0/,"");
787 |
788 | return text;
789 | }
790 |
791 | _ProcessListItems = function(list_str) {
792 | //
793 | // Process the contents of a single ordered or unordered list, splitting it
794 | // into individual list items.
795 | //
796 | // The $g_list_level global keeps track of when we're inside a list.
797 | // Each time we enter a list, we increment it; when we leave a list,
798 | // we decrement. If it's zero, we're not in a list anymore.
799 | //
800 | // We do this because when we're not inside a list, we want to treat
801 | // something like this:
802 | //
803 | // I recommend upgrading to version
804 | // 8. Oops, now this line is treated
805 | // as a sub-list.
806 | //
807 | // As a single paragraph, despite the fact that the second line starts
808 | // with a digit-period-space sequence.
809 | //
810 | // Whereas when we're inside a list (or sub-list), that line will be
811 | // treated as the start of a sub-list. What a kludge, huh? This is
812 | // an aspect of Markdown's syntax that's hard to parse perfectly
813 | // without resorting to mind-reading. Perhaps the solution is to
814 | // change the syntax rules such that sub-lists must start with a
815 | // starting cardinal number; e.g. "1." or "a.".
816 |
817 | g_list_level++;
818 |
819 | // trim trailing blank lines:
820 | list_str = list_str.replace(/\n{2,}$/,"\n");
821 |
822 | // attacklab: add sentinel to emulate \z
823 | list_str += "~0";
824 |
825 | /*
826 | list_str = list_str.replace(/
827 | (\n)? // leading line = $1
828 | (^[ \t]*) // leading whitespace = $2
829 | ([*+-]|\d+[.]) [ \t]+ // list marker = $3
830 | ([^\r]+? // list item text = $4
831 | (\n{1,2}))
832 | (?= \n* (~0 | \2 ([*+-]|\d+[.]) [ \t]+))
833 | /gm, function(){...});
834 | */
835 | list_str = list_str.replace(/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,
836 | function(wholeMatch,m1,m2,m3,m4){
837 | var item = m4;
838 | var leading_line = m1;
839 | var leading_space = m2;
840 |
841 | if (leading_line || (item.search(/\n{2,}/)>-1)) {
842 | item = _RunBlockGamut(_Outdent(item));
843 | }
844 | else {
845 | // Recursion for sub-lists:
846 | item = _DoLists(_Outdent(item));
847 | item = item.replace(/\n$/,""); // chomp(item)
848 | item = _RunSpanGamut(item);
849 | }
850 |
851 | return "
");});
693 |
694 | // atx-style headers:
695 | // # Header 1
696 | // ## Header 2
697 | // ## Header 2 with closing hashes ##
698 | // ...
699 | // ###### Header 6
700 | //
701 |
702 | /*
703 | text = text.replace(/
704 | ^(\#{1,6}) // $1 = string of #'s
705 | [ \t]*
706 | (.+?) // $2 = Header text
707 | [ \t]*
708 | \#* // optional closing #'s (not counted)
709 | \n+
710 | /gm, function() {...});
711 | */
712 |
713 | text = text.replace(/^([#=]{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,
714 | function(wholeMatch,m1,m2) {
715 | var h_level = m1.length;
716 | return hashBlock("" + _RunSpanGamut(m2) + "");
717 | });
718 |
719 | return text;
720 | }
721 |
722 | // This declaration keeps Dojo compressor from outputting garbage:
723 | var _ProcessListItems;
724 |
725 | var _DoLists = function(text) {
726 | //
727 | // Form HTML ordered (numbered) and unordered (bulleted) lists.
728 | //
729 |
730 | // attacklab: add sentinel to hack around khtml/safari bug:
731 | // http://bugs.webkit.org/show_bug.cgi?id=11231
732 | text += "~0";
733 |
734 | // Re-usable pattern to match any entirel ul or ol list:
735 |
736 | /*
737 | var whole_list = /
738 | ( // $1 = whole list
739 | ( // $2
740 | [ ]{0,1} // attacklab: g_tab_width - 1
741 | ([*+-]|\d+[.]) // $3 = first list item marker
742 | [ \t]+
743 | )
744 | [^\r]+?
745 | ( // $4
746 | ~0 // sentinel for workaround; should be $
747 | |
748 | \n{2,}
749 | (?=\S)
750 | (?! // Negative lookahead for another list item marker
751 | [ \t]*
752 | (?:[*+-]|\d+[.])[ \t]+
753 | )
754 | )
755 | )/g
756 | */
757 | var whole_list = /^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;
758 |
759 | if (g_list_level) {
760 | text = text.replace(whole_list,function(wholeMatch,m1,m2) {
761 | var list = m1;
762 | var list_type = (m2.search(/[*+-]/g)>-1) ? "ul" : "ol";
763 |
764 | // Turn double returns into triple returns, so that we can make a
765 | // paragraph for the last item in a list, if necessary:
766 | list = list.replace(/\n{2,}/g,"\n\n\n");;
767 | var result = _ProcessListItems(list);
768 |
769 | // Trim any trailing whitespace, to put the closing `$list_type>`
770 | // up on the preceding line, to get it past the current stupid
771 | // HTML block parser. This is a hack to work around the terrible
772 | // hack that is the HTML block parser.
773 | result = result.replace(/\s+$/,"");
774 | result = "<"+list_type+">" + result + ""+list_type+">\n";
775 | return result;
776 | });
777 | } else {
778 | whole_list = /(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g;
779 | text = text.replace(whole_list,function(wholeMatch,m1,m2,m3) {
780 | var runup = m1;
781 | var list = m2;
782 |
783 | var list_type = (m3.search(/[*+-]/g)>-1) ? "ul" : "ol";
784 | // Turn double returns into triple returns, so that we can make a
785 | // paragraph for the last item in a list, if necessary:
786 | var list = list.replace(/\n{2,}/g,"\n\n\n");;
787 | var result = _ProcessListItems(list);
788 | result = runup + "<"+list_type+">\n" + result + ""+list_type+">\n";
789 | return result;
790 | });
791 | }
792 |
793 | // attacklab: strip sentinel
794 | text = text.replace(/~0/,"");
795 |
796 | return text;
797 | }
798 |
799 | _ProcessListItems = function(list_str) {
800 | //
801 | // Process the contents of a single ordered or unordered list, splitting it
802 | // into individual list items.
803 | //
804 | // The $g_list_level global keeps track of when we're inside a list.
805 | // Each time we enter a list, we increment it; when we leave a list,
806 | // we decrement. If it's zero, we're not in a list anymore.
807 | //
808 | // We do this because when we're not inside a list, we want to treat
809 | // something like this:
810 | //
811 | // I recommend upgrading to version
812 | // 8. Oops, now this line is treated
813 | // as a sub-list.
814 | //
815 | // As a single paragraph, despite the fact that the second line starts
816 | // with a digit-period-space sequence.
817 | //
818 | // Whereas when we're inside a list (or sub-list), that line will be
819 | // treated as the start of a sub-list. What a kludge, huh? This is
820 | // an aspect of Markdown's syntax that's hard to parse perfectly
821 | // without resorting to mind-reading. Perhaps the solution is to
822 | // change the syntax rules such that sub-lists must start with a
823 | // starting cardinal number; e.g. "1." or "a.".
824 |
825 | g_list_level++;
826 |
827 | // trim trailing blank lines:
828 | list_str = list_str.replace(/\n{2,}$/,"\n");
829 |
830 | // attacklab: add sentinel to emulate \z
831 | list_str += "~0";
832 |
833 | /*
834 | list_str = list_str.replace(/
835 | (\n)? // leading line = $1
836 | (^[ \t]*) // leading whitespace = $2
837 | ([*+-]|\d+[.]) [ \t]+ // list marker = $3
838 | ([^\r]+? // list item text = $4
839 | (\n{1,2}))
840 | (?= \n* (~0 | \2 ([*+-]|\d+[.]) [ \t]+))
841 | /gm, function(){...});
842 | */
843 | list_str = list_str.replace(/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,
844 | function(wholeMatch,m1,m2,m3,m4){
845 | var item = m4;
846 | var leading_line = m1;
847 | var leading_space = m2;
848 |
849 | if (leading_line || (item.search(/\n{2,}/)>-1)) {
850 | item = _RunBlockGamut(_Outdent(item));
851 | }
852 | else {
853 | // Recursion for sub-lists:
854 | item = _DoLists(_Outdent(item));
855 | item = item.replace(/\n$/,""); // chomp(item)
856 | item = _RunSpanGamut(item);
857 | }
858 |
859 | return "
" + item + "
\n";
860 | }
861 | );
862 |
863 | // attacklab: strip sentinel
864 | list_str = list_str.replace(/~0/g,"");
865 |
866 | g_list_level--;
867 | return list_str;
868 | }
869 |
870 | /*
871 | Regular expression to parse code blocks.
872 | /(?:\n\n|^)
873 | ( // $1 = the code block -- one or more lines, starting with a space/tab
874 | (?:
875 | (?:[ ]{2}|\t) // Lines must start with a tab or a tab-width of spaces - attacklab: g_tab_width
876 | .*\n+
877 | )+
878 | )
879 | (\n*[ ]{0,1}[^ \t\n]|(?=~0)) // attacklab: g_tab_width - 1
880 | /g,function(){...});
881 | */
882 | var _RE_DoCodeBlocks = new RegExp(
883 | '(?:\n\n|^)((?:(?:[ ]{' + g_tab_width + '}|\t).*\n+)+)(\n*[ ]{0,' + (g_tab_width - 1) + '}[^ \t\n]|(?=~0))', 'g'
884 | );
885 |
886 | var _DoCodeBlocks = function(text) {
887 | //
888 | // Process Markdown `
` blocks.
889 | //
890 |
891 | // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
892 | text += "~0";
893 |
894 | //text = text.replace(/(?:\n\n|^)((?:(?:[ ]{2}|\t).*\n+)+)(\n*[ ]{0,1}[^ \t\n]|(?=~0))/g,
895 | text = text.replace(_RE_DoCodeBlocks,
896 | function(wholeMatch,m1,m2) {
897 | var codeblock = m1;
898 | var nextChar = m2;
899 |
900 | codeblock = _EncodeCode( _Outdent(codeblock));
901 | codeblock = _Detab(codeblock);
902 | codeblock = codeblock.replace(/^\n+/g,""); // trim leading newlines
903 | codeblock = codeblock.replace(/\n+$/g,""); // trim trailing whitespace
904 |
905 | codeblock = "
" + codeblock + "\n
";
906 |
907 | return hashBlock(codeblock) + nextChar;
908 | }
909 | );
910 |
911 | // attacklab: strip sentinel
912 | text = text.replace(/~0/,"");
913 |
914 | return text;
915 | }
916 |
917 | var hashBlock = function(text) {
918 | text = text.replace(/(^\n+|\n+$)/g,"");
919 | return "\n\n~K" + (g_html_blocks.push(text)-1) + "K\n\n";
920 | }
921 |
922 |
923 | var _DoCodeSpans = function(text) {
924 | //
925 | // * Backtick quotes are used for spans.
926 | //
927 | // * You can use multiple backticks as the delimiters if you want to
928 | // include literal backticks in the code span. So, this input:
929 | //
930 | // Just type ``foo `bar` baz`` at the prompt.
931 | //
932 | // Will translate to:
933 | //
934 | //
Just type foo `bar` baz at the prompt.
935 | //
936 | // There's no arbitrary limit to the number of backticks you
937 | // can use as delimters. If you need three consecutive backticks
938 | // in your code, use four for delimiters, etc.
939 | //
940 | // * You can use spaces to get literal backticks at the edges:
941 | //
942 | // ... type `` `bar` `` ...
943 | //
944 | // Turns to:
945 | //
946 | // ... type `bar` ...
947 | //
948 |
949 | /*
950 | text = text.replace(/
951 | (^|[^\\]) // Character before opening ` can't be a backslash
952 | (`+) // $2 = Opening run of `
953 | ( // $3 = The code block
954 | [^\r]*?
955 | [^`] // attacklab: work around lack of lookbehind
956 | )
957 | \2 // Matching closer
958 | (?!`)
959 | /gm, function(){...});
960 | */
961 |
962 | text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,
963 | function(wholeMatch,m1,m2,m3,m4) {
964 | var c = m3;
965 | c = c.replace(/^([ \t]*)/g,""); // leading whitespace
966 | c = c.replace(/[ \t]*$/g,""); // trailing whitespace
967 | c = _EncodeCode(c);
968 | return m1+""+c+"";
969 | });
970 |
971 | return text;
972 | }
973 |
974 |
975 | var _EncodeCode = function(text) {
976 | //
977 | // Encode/escape certain characters inside Markdown code runs.
978 | // The point is that in code, these characters are literals,
979 | // and lose their special Markdown meanings.
980 | //
981 | // Encode all ampersands; HTML entities are not
982 | // entities within a Markdown code span.
983 | text = text.replace(/&/g,"&");
984 |
985 | // Do the angle bracket song and dance:
986 | text = text.replace(//g,">");
988 |
989 | // Now, escape characters that are magic in Markdown:
990 | text = escapeCharacters(text,"\*_{}[]\\",false);
991 |
992 | // jj the line above breaks this:
993 | //---
994 |
995 | //* Item
996 |
997 | // 1. Subitem
998 |
999 | // special char: *
1000 | //---
1001 |
1002 | return text;
1003 | }
1004 |
1005 |
1006 | var _DoItalicsAndBold = function(text) {
1007 |
1008 | // must go first:
1009 | text = text.replace(/(\*\*|__)(?=\S)([^\r]*?\S[\*_]*)\1/g,
1010 | "$2");
1011 |
1012 | text = text.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,
1013 | "$2");
1014 |
1015 | return text;
1016 | }
1017 |
1018 |
1019 | var _DoBlockQuotes = function(text) {
1020 |
1021 | /*
1022 | text = text.replace(/
1023 | ( // Wrap whole match in $1
1024 | (
1025 | ^[ \t]*>[ \t]? // '>' at the start of a line
1026 | .+\n // rest of the first line
1027 | (.+\n)* // subsequent consecutive lines
1028 | \n* // blanks
1029 | )+
1030 | )
1031 | /gm, function(){...});
1032 | */
1033 |
1034 | text = text.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,
1035 | function(wholeMatch,m1) {
1036 | var bq = m1;
1037 |
1038 | // attacklab: hack around Konqueror 3.5.4 bug:
1039 | // "----------bug".replace(/^-/g,"") == "bug"
1040 |
1041 | bq = bq.replace(/^[ \t]*>[ \t]?/gm,"~0"); // trim one level of quoting
1042 |
1043 | // attacklab: clean up hack
1044 | bq = bq.replace(/~0/g,"");
1045 |
1046 | bq = bq.replace(/^[ \t]+$/gm,""); // trim whitespace-only lines
1047 | bq = _RunBlockGamut(bq); // recurse
1048 |
1049 | bq = bq.replace(/(^|\n)/g,"$1 ");
1050 | // These leading spaces screw with
content, so we need to fix that:
1051 | bq = bq.replace(
1052 | /(\s*
[^\r]+?<\/pre>)/gm,
1053 | function(wholeMatch,m1) {
1054 | var pre = m1;
1055 | // attacklab: hack around Konqueror 3.5.4 bug:
1056 | pre = pre.replace(/^ /mg,"~0");
1057 | pre = pre.replace(/~0/g,"");
1058 | return pre;
1059 | });
1060 |
1061 | return hashBlock("
\n" + bq + "\n
");
1062 | });
1063 | return text;
1064 | }
1065 |
1066 |
1067 | var _FormParagraphs = function(text) {
1068 | //
1069 | // Params:
1070 | // $text - string to process with html
tags
1071 | //
1072 |
1073 | // Strip leading and trailing lines:
1074 | text = text.replace(/^\n+/g,"");
1075 | text = text.replace(/\n+$/g,"");
1076 |
1077 | var grafs = text.split(/\n{2,}/g);
1078 | var grafsOut = new Array();
1079 |
1080 | //
1081 | // Wrap